From 5d4bd2fee603a9586da650d6ef3a4886c5efa7cf Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:49:53 +0800 Subject: [PATCH] Fix possible issues with load balancing https://github.com/2dust/v2rayN/issues/6429 --- v2rayN/ServiceLib/Sample/SampleClientConfig | 37 +++++++++---------- .../CoreConfig/CoreConfigSingboxService.cs | 2 +- .../CoreConfig/CoreConfigV2rayService.cs | 2 +- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/v2rayN/ServiceLib/Sample/SampleClientConfig b/v2rayN/ServiceLib/Sample/SampleClientConfig index 98c58e0e..407a1307 100644 --- a/v2rayN/ServiceLib/Sample/SampleClientConfig +++ b/v2rayN/ServiceLib/Sample/SampleClientConfig @@ -5,24 +5,25 @@ "loglevel": "warning" }, "inbounds": [], - "outbounds": [{ + "outbounds": [ + { "tag": "proxy", "protocol": "vmess", "settings": { "vnext": [{ - "address": "v2ray.cool", - "port": 10086, + "address": "", + "port": 0, "users": [{ - "id": "a3482e88-686a-4a58-8126-99c9df64b7bf", + "id": "", "security": "auto" }] }], "servers": [{ - "address": "v2ray.cool", - "method": "chacha20", + "address": "", + "method": "", "ota": false, - "password": "123456", - "port": 10086, + "password": "", + "port": 0, "level": 1 }] }, @@ -35,27 +36,23 @@ }, { "protocol": "freedom", - "settings": {}, "tag": "direct" }, { "protocol": "blackhole", - "tag": "block", - "settings": { - "response": { - "type": "http" - } - } + "tag": "block" } ], "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ - { - "inboundTag": ["api"], - "outboundTag": "api", - "type": "field" - } + { + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "type": "field" + } ] } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 91d17d44..2db53ad7 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -313,7 +313,7 @@ namespace ServiceLib.Services.CoreConfig var outbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(item, outbound); outbound.tag = $"{Global.ProxyTag}-{tagProxy.Count + 1}"; - singboxConfig.outbounds.Add(outbound); + singboxConfig.outbounds.Insert(0, outbound); tagProxy.Add(outbound.tag); } if (tagProxy.Count <= 0) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 8f71460a..289960cf 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -154,7 +154,7 @@ namespace ServiceLib.Services.CoreConfig var outbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(item, outbound); outbound.tag = $"{Global.ProxyTag}-{tagProxy.Count + 1}"; - v2rayConfig.outbounds.Add(outbound); + v2rayConfig.outbounds.Insert(0, outbound); tagProxy.Add(outbound.tag); } if (tagProxy.Count <= 0)