Browse Source

Merge pull request #2101 from studentmain/master

Fix #2100 NullReference
tags/4.1.3.1
Allen Zhu GitHub 6 years ago
parent
commit
a79bc04ec5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions
  1. +1
    -0
      shadowsocks-csharp/Model/SysproxyConfig.cs
  2. +7
    -7
      shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs

+ 1
- 0
shadowsocks-csharp/Model/SysproxyConfig.cs View File

@@ -19,6 +19,7 @@ namespace Shadowsocks.Model
{ {
UserSettingsRecorded = false; UserSettingsRecorded = false;
Flags = "1"; Flags = "1";
// Watchout, Nullable! See #2100
ProxyServer = ""; ProxyServer = "";
BypassList = ""; BypassList = "";
PacUrl = ""; PacUrl = "";


+ 7
- 7
shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs View File

@@ -16,7 +16,7 @@ namespace Shadowsocks.Util.SystemProxy
{ {
private const string _userWininetConfigFile = "user-wininet.json"; private const string _userWininetConfigFile = "user-wininet.json";
private static string[] _lanIP = {
private readonly static string[] _lanIP = {
"<local>", "<local>",
"localhost", "localhost",
"127.*", "127.*",
@@ -88,10 +88,11 @@ namespace Shadowsocks.Util.SystemProxy
string arguments; string arguments;
if (enable) if (enable)
{ {
List<string> customBypass = new List<string>(_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<string> customBypassList = new List<string>(customBypassString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
customBypassList.AddRange(_lanIP);
string[] realBypassList = customBypassList.Distinct().ToArray();
string realBypassString = string.Join(";", realBypassList);
arguments = global arguments = global
? $"global {proxyServer} {realBypassString}" ? $"global {proxyServer} {realBypassString}"
@@ -114,7 +115,6 @@ namespace Shadowsocks.Util.SystemProxy
ExecSysproxy(arguments); ExecSysproxy(arguments);
} }
// set system proxy to 1 (null) (null) (null) // set system proxy to 1 (null) (null) (null)
public static bool ResetIEProxy() public static bool ResetIEProxy()
{ {
@@ -126,7 +126,7 @@ namespace Shadowsocks.Util.SystemProxy
// clear system setting // clear system setting
ExecSysproxy("set 1 - - -"); ExecSysproxy("set 1 - - -");
} }
catch (Exception e)
catch (Exception)
{ {
return false; return false;
} }


Loading…
Cancel
Save