From 3314b4ac8c61a1bafdc0ed642cd16042188d3d91 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Mon, 9 Feb 2026 10:48:54 +0800 Subject: [PATCH] Fix --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 31 ++++++++-------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 26619666..b9a369ec 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1233,28 +1233,19 @@ public static class ConfigHandler /// A SOCKS profile item or null if not needed public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType) { + if (node.ConfigType != EConfigType.Custom || !(node.PreSocksPort > 0)) + { + return null; + } ProfileItem? itemSocks = null; - if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && config.TunModeItem.EnableTun) + var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray; + itemSocks = new ProfileItem() { - itemSocks = new ProfileItem() - { - CoreType = ECoreType.sing_box, - ConfigType = EConfigType.SOCKS, - Address = Global.Loopback, - Port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks) - }; - } - else if (node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0) - { - var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray; - itemSocks = new ProfileItem() - { - CoreType = preCoreType, - ConfigType = EConfigType.SOCKS, - Address = Global.Loopback, - Port = node.PreSocksPort.Value, - }; - } + CoreType = preCoreType, + ConfigType = EConfigType.SOCKS, + Address = Global.Loopback, + Port = node.PreSocksPort.Value, + }; return itemSocks; }