From b12b7a17e6c854acd7ab0ddd0049b8e04c3ec1a5 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:31:32 +0800 Subject: [PATCH] Fix possible issues with load balancing --- .../Services/CoreConfig/CoreConfigSingboxService.cs | 4 ++-- .../Services/CoreConfig/CoreConfigV2rayService.cs | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 2db53ad7..e4268916 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -333,7 +333,7 @@ namespace ServiceLib.Services.CoreConfig outbounds = tagProxy, interrupt_exist_connections = false, }; - singboxConfig.outbounds.Add(outUrltest); + singboxConfig.outbounds.Insert(0, outUrltest); //add selector outbound var outSelector = new Outbound4Sbox @@ -344,7 +344,7 @@ namespace ServiceLib.Services.CoreConfig interrupt_exist_connections = false, }; outSelector.outbounds.Insert(0, outUrltest.tag); - singboxConfig.outbounds.Add(outSelector); + singboxConfig.outbounds.Insert(0, outSelector); ret.Success = true; ret.Data = JsonUtils.Serialize(singboxConfig); diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 289960cf..afa426a8 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -182,15 +182,12 @@ namespace ServiceLib.Services.CoreConfig rule.balancerTag = balancer.tag; } } - else + v2rayConfig.routing.rules.Add(new() { - v2rayConfig.routing.rules.Add(new() - { - network = "tcp,udp", - balancerTag = balancer.tag, - type = "field" - }); - } + network = "tcp,udp", + balancerTag = balancer.tag, + type = "field" + }); ret.Success = true; ret.Data = JsonUtils.Serialize(v2rayConfig);