From 5f5d7172ee58e022bf336c584318ec0802758ca5 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:38:23 +0800 Subject: [PATCH] Optimize system proxy exceptions --- v2rayN/ServiceLib/Global.cs | 3 ++- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 9 +++++++-- v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 4edaa855..a8b843c7 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -68,7 +68,8 @@ public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run"; public const string AutoRunName = "v2rayNAutoRun"; public const string CustomIconName = "v2rayN.ico"; - public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*"; + public const string SystemProxyExceptionsWindows = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*"; + public const string SystemProxyExceptionsLinux = "localhost, 127.0.0.0/8, ::1"; public const string RoutingRuleComma = ""; public const string GrpcGunMode = "gun"; public const string GrpcMultiMode = "multi"; diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 1639592f..8c066868 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -120,9 +120,14 @@ namespace ServiceLib.Handler } config.ConstItem ??= new ConstItem(); - if (Utils.IsNullOrEmpty(config.ConstItem.DefIEProxyExceptions)) + if (Utils.IsNotEmpty(config.ConstItem.DefIEProxyExceptions)) { - config.ConstItem.DefIEProxyExceptions = Global.IEProxyExceptions; + config.SystemProxyItem.SystemProxyExceptions = $"{config.ConstItem.DefIEProxyExceptions};{config.SystemProxyItem.SystemProxyExceptions}"; + config.ConstItem.DefIEProxyExceptions = string.Empty; + } + if (config.SystemProxyItem.SystemProxyExceptions.IsNullOrEmpty()) + { + config.SystemProxyItem.SystemProxyExceptions = Utils.IsWindows() ? Global.SystemProxyExceptionsWindows : Global.SystemProxyExceptionsLinux; } config.SpeedTestItem ??= new(); diff --git a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs index 0230b0a4..6e54c506 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs @@ -65,7 +65,7 @@ private static void GetWindowsProxyString(Config config, int port, out string strProxy, out string strExceptions) { - strExceptions = $"{config.ConstItem.DefIEProxyExceptions};{config.SystemProxyItem.SystemProxyExceptions}"; + strExceptions = config.SystemProxyItem.SystemProxyExceptions; if (config.SystemProxyItem.NotProxyLocalAddress) { strExceptions = $";{strExceptions}";