From 9368f444d5d9d8da41055b42589e9d236a8fe396 Mon Sep 17 00:00:00 2001 From: Student Main Date: Sat, 8 Dec 2018 15:06:34 +0800 Subject: [PATCH] https://github.com/shadowsocks/shadowsocks-windows/issues/2100#issuecomment-445434934 --- shadowsocks-csharp/Model/SysproxyConfig.cs | 1 + shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/shadowsocks-csharp/Model/SysproxyConfig.cs b/shadowsocks-csharp/Model/SysproxyConfig.cs index f7ba1402..53e78a6e 100644 --- a/shadowsocks-csharp/Model/SysproxyConfig.cs +++ b/shadowsocks-csharp/Model/SysproxyConfig.cs @@ -19,6 +19,7 @@ namespace Shadowsocks.Model { UserSettingsRecorded = false; Flags = "1"; + // Watchout, Nullable! See #2100 ProxyServer = ""; BypassList = ""; PacUrl = ""; diff --git a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs index f0d7fff9..9c7fe067 100644 --- a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs +++ b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs @@ -16,7 +16,7 @@ namespace Shadowsocks.Util.SystemProxy { private const string _userWininetConfigFile = "user-wininet.json"; - private static string[] _lanIP = { + private readonly static string[] _lanIP = { "", "localhost", "127.*", @@ -88,10 +88,11 @@ namespace Shadowsocks.Util.SystemProxy string arguments; if (enable) { - List customBypass = new List(_userSettings.BypassList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); - customBypass.AddRange(_lanIP); - string[] realBypassStrings = customBypass.Distinct().ToArray(); - string realBypassString = string.Join(";", realBypassStrings); + string customBypassString = _userSettings.BypassList ?? ""; + List customBypassList = new List(customBypassString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); + customBypassList.AddRange(_lanIP); + string[] realBypassList = customBypassList.Distinct().ToArray(); + string realBypassString = string.Join(";", realBypassList); arguments = global ? $"global {proxyServer} {realBypassString}" @@ -114,7 +115,6 @@ namespace Shadowsocks.Util.SystemProxy ExecSysproxy(arguments); } - // set system proxy to 1 (null) (null) (null) public static bool ResetIEProxy() { @@ -126,7 +126,7 @@ namespace Shadowsocks.Util.SystemProxy // clear system setting ExecSysproxy("set 1 - - -"); } - catch (Exception e) + catch (Exception) { return false; }