From cb9102305570cde9bbc096c1f97987b227ce86fd Mon Sep 17 00:00:00 2001 From: hiddify-com <114227601+hiddify-com@users.noreply.github.com> Date: Sat, 27 Jul 2024 22:59:21 +0200 Subject: [PATCH] better xray support --- lib/singbox/model/singbox_outbound.dart | 13 +++++-------- lib/singbox/model/singbox_proxy_type.dart | 10 +++++++++- libcore | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/singbox/model/singbox_outbound.dart b/lib/singbox/model/singbox_outbound.dart index 556c40d7..54bdc56e 100644 --- a/lib/singbox/model/singbox_outbound.dart +++ b/lib/singbox/model/singbox_outbound.dart @@ -15,8 +15,7 @@ class SingboxOutboundGroup with _$SingboxOutboundGroup { @Default([]) List items, }) = _SingboxOutboundGroup; - factory SingboxOutboundGroup.fromJson(Map json) => - _$SingboxOutboundGroupFromJson(json); + factory SingboxOutboundGroup.fromJson(Map json) => _$SingboxOutboundGroupFromJson(json); } @freezed @@ -30,11 +29,9 @@ class SingboxOutboundGroupItem with _$SingboxOutboundGroupItem { required int urlTestDelay, }) = _SingboxOutboundGroupItem; - factory SingboxOutboundGroupItem.fromJson(Map json) => - _$SingboxOutboundGroupItemFromJson(json); + factory SingboxOutboundGroupItem.fromJson(Map json) => _$SingboxOutboundGroupItemFromJson(json); } -ProxyType _typeFromJson(dynamic type) => - ProxyType.values - .firstOrNullWhere((e) => e.key == (type as String?)?.toLowerCase()) ?? - ProxyType.unknown; +final Map _keyMap = Map.fromEntries(ProxyType.values.map((e) => MapEntry(e.key, e))); + +ProxyType _typeFromJson(dynamic type) => ProxyType.fromJson(type); diff --git a/lib/singbox/model/singbox_proxy_type.dart b/lib/singbox/model/singbox_proxy_type.dart index 5716d343..4a638c7c 100644 --- a/lib/singbox/model/singbox_proxy_type.dart +++ b/lib/singbox/model/singbox_proxy_type.dart @@ -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 groupValues = [selector, urltest]; bool get isGroup => ProxyType.groupValues.contains(this); + static final Map _keyMap = Map.fromEntries(ProxyType.values.map((e) => MapEntry(e.key, e))); + static ProxyType fromJson(dynamic type) => _keyMap[(type as String?)?.toLowerCase()] ?? ProxyType.unknown; } diff --git a/libcore b/libcore index a100263c..e6db5f23 160000 --- a/libcore +++ b/libcore @@ -1 +1 @@ -Subproject commit a100263c960aaa0f467a7a57fb8b0454811d4a6d +Subproject commit e6db5f23487b93fa7e78f9f8912c767deca31067