From 916e6d20503e01545bb06ca5fca506f2731c005b Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sun, 27 Jul 2025 20:05:19 +0800 Subject: [PATCH] Avoids detour for private networks --- .../ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs | 2 +- v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 8e5f1a4b..e60e77fb 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -2232,7 +2232,7 @@ public class CoreConfigSingboxService continue; } } - else if (outbound.detour.IsNullOrEmpty() && (!customConfig.ProxyDetour.IsNullOrEmpty())) + else if (outbound.detour.IsNullOrEmpty() && (!customConfig.ProxyDetour.IsNullOrEmpty()) && !Utils.IsPrivateNetwork(outbound.server ?? string.Empty)) { outbound.detour = customConfig.ProxyDetour; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 99c945ca..2a59d91a 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -1910,7 +1910,7 @@ public class CoreConfigV2rayService continue; } } - else if ((outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() == true) && (!customConfig.ProxyDetour.IsNullOrEmpty())) + else if ((outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() == true) && (!customConfig.ProxyDetour.IsNullOrEmpty()) && !(Utils.IsPrivateNetwork(outbound.settings?.servers?.FirstOrDefault()?.address ?? string.Empty) || Utils.IsPrivateNetwork(outbound.settings?.vnext?.FirstOrDefault()?.address ?? string.Empty))) { outbound.streamSettings ??= new StreamSettings4Ray(); outbound.streamSettings.sockopt ??= new Sockopt4Ray();