better xray support

This commit is contained in:
hiddify-com
2024-07-27 22:59:21 +02:00
parent 47b5a9788f
commit cb91023055
3 changed files with 15 additions and 10 deletions

View File

@@ -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
@@ -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);

View File

@@ -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);
@@ -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;
}