From fad94e68d2b8cf534ec65a91fd8211ea74da74aa Mon Sep 17 00:00:00 2001 From: DHR60 Date: Fri, 12 Sep 2025 11:35:20 +0800 Subject: [PATCH] Avoid duplicate tags --- .../Singbox/SingboxRoutingService.cs | 29 ++++++++++--------- .../CoreConfig/V2ray/V2rayRoutingService.cs | 25 ++++++++-------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs index 522ba86a..2dd63349 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs @@ -369,6 +369,20 @@ public partial class CoreConfigSingboxService var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); + if (node == null + || (!Global.SingboxSupportConfigType.Contains(node.ConfigType) + && node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))) + { + return Global.ProxyTag; + } + + var tag = Global.ProxyTag + node.IndexId.ToString(); + if (singboxConfig.outbounds.Any(o => o.tag == tag) + || (singboxConfig.endpoints != null && singboxConfig.endpoints.Any(e => e.tag == tag))) + { + return tag; + } + if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain) { ProfileGroupItemManager.Instance.TryGet(node.IndexId, out var profileGroupItem); @@ -401,26 +415,13 @@ public partial class CoreConfigSingboxService return Global.ProxyTag; } - if (node == null - || !Global.SingboxSupportConfigType.Contains(node.ConfigType)) - { - return Global.ProxyTag; - } - - var tag = Global.ProxyTag + node.IndexId.ToString(); - if (singboxConfig.outbounds.Any(o => o.tag == tag) - || (singboxConfig.endpoints != null && singboxConfig.endpoints.Any(e => e.tag == tag))) - { - return tag; - } - var server = await GenServer(node); if (server is null) { return Global.ProxyTag; } - server.tag = Global.ProxyTag + node.IndexId.ToString(); + server.tag = tag; if (server is Endpoints4Sbox endpoint) { singboxConfig.endpoints ??= new(); diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs index 27bffeb6..50862c66 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs @@ -126,6 +126,19 @@ public partial class CoreConfigV2rayService var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); + if (node == null + || (!Global.XraySupportConfigType.Contains(node.ConfigType) + && node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))) + { + return Global.ProxyTag; + } + + var tag = Global.ProxyTag + node.IndexId.ToString(); + if (v2rayConfig.outbounds.Any(p => p.tag == tag)) + { + return tag; + } + if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain) { ProfileGroupItemManager.Instance.TryGet(node.IndexId, out var profileGroupItem); @@ -162,18 +175,6 @@ public partial class CoreConfigV2rayService return Global.ProxyTag; } - if (node == null - || !Global.XraySupportConfigType.Contains(node.ConfigType)) - { - return Global.ProxyTag; - } - - var tag = Global.ProxyTag + node.IndexId.ToString(); - if (v2rayConfig.outbounds.Any(p => p.tag == tag)) - { - return tag; - } - var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound); var outbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(node, outbound);