Skip to content

Commit

Permalink
better xray support
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jul 27, 2024
1 parent 47b5a97 commit cb91023
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 5 additions & 8 deletions lib/singbox/model/singbox_outbound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class SingboxOutboundGroup with _$SingboxOutboundGroup {
@Default([]) List<SingboxOutboundGroupItem> items,
}) = _SingboxOutboundGroup;

factory SingboxOutboundGroup.fromJson(Map<String, dynamic> json) =>
_$SingboxOutboundGroupFromJson(json);
factory SingboxOutboundGroup.fromJson(Map<String, dynamic> json) => _$SingboxOutboundGroupFromJson(json);
}

@freezed
Expand All @@ -30,11 +29,9 @@ class SingboxOutboundGroupItem with _$SingboxOutboundGroupItem {
required int urlTestDelay,
}) = _SingboxOutboundGroupItem;

factory SingboxOutboundGroupItem.fromJson(Map<String, dynamic> json) =>
_$SingboxOutboundGroupItemFromJson(json);
factory SingboxOutboundGroupItem.fromJson(Map<String, dynamic> json) => _$SingboxOutboundGroupItemFromJson(json);
}

ProxyType _typeFromJson(dynamic type) =>
ProxyType.values
.firstOrNullWhere((e) => e.key == (type as String?)?.toLowerCase()) ??
ProxyType.unknown;
final Map<String, ProxyType> _keyMap = Map.fromEntries(ProxyType.values.map((e) => MapEntry(e.key, e)));

ProxyType _typeFromJson(dynamic type) => ProxyType.fromJson(type);
10 changes: 9 additions & 1 deletion lib/singbox/model/singbox_proxy_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ enum ProxyType {
selector("Selector"),
urltest("URLTest"),
warp("Warp"),
xray("XRay"),

xvless("XVLESS"),
xvmess("XVMess"),
xtrojan("Xtrojan"),
xfreedom("Xfragment"),
xshadowsocks("XShadowsocks"),
xsocks("XSocks"),
unknown("Unknown");

const ProxyType(this.label);
Expand All @@ -33,4 +39,6 @@ enum ProxyType {
static List<ProxyType> groupValues = [selector, urltest];

bool get isGroup => ProxyType.groupValues.contains(this);
static final Map<String, ProxyType> _keyMap = Map.fromEntries(ProxyType.values.map((e) => MapEntry(e.key, e)));
static ProxyType fromJson(dynamic type) => _keyMap[(type as String?)?.toLowerCase()] ?? ProxyType.unknown;
}
2 changes: 1 addition & 1 deletion libcore

0 comments on commit cb91023

Please sign in to comment.