diff --git a/shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs b/shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs index 9bfb769a58..6200004b52 100644 --- a/shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs +++ b/shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs @@ -22,6 +22,7 @@ public class ChnDomainsAndIPUpdater private static readonly string PAC_FILE = PACServer.PAC_FILE; private static readonly string USER_RULE_FILE = PACServer.WHITELIST_FILE; + private static readonly string USER_TEMPLATE_FILE = PACServer.USER_WHITELIST_TEMPLATE_FILE; private static string SS_template = null; private static string cnIpRange = null; @@ -58,7 +59,24 @@ private void HttpDownloadSSCNIPTemplateCompleted(object sender, DownloadStringCo { try { - var result = e.Result; + string result; + if (File.Exists(USER_TEMPLATE_FILE)) + { + result = File.ReadAllText(USER_TEMPLATE_FILE, Encoding.UTF8); + if (result.IndexOf(@"__cnIpRange__", StringComparison.Ordinal) > 0 + && result.IndexOf(@"__cnIp16Range__", StringComparison.Ordinal) > 0 + && result.IndexOf(@"__white_domains__", StringComparison.Ordinal) > 0 + && result.IndexOf(@"FindProxyForURL", StringComparison.Ordinal) > 0) + { + SS_template = result; + if (lastConfig != null && lastTemplate != Templates.None) + { + UpdatePACFromChnDomainsAndIP(lastConfig, lastTemplate); + } + return; + } + } + result = e.Result; if (result.IndexOf(@"__cnIpRange__", StringComparison.Ordinal) > 0 && result.IndexOf(@"__cnIp16Range__", StringComparison.Ordinal) > 0 && result.IndexOf(@"__white_domains__", StringComparison.Ordinal) > 0 @@ -72,7 +90,7 @@ private void HttpDownloadSSCNIPTemplateCompleted(object sender, DownloadStringCo } else { - Error?.Invoke(this, new ErrorEventArgs(new Exception(@"Download ERROR"))); + Error?.Invoke(this, new ErrorEventArgs(new Exception(@"WhiteList Template ERROR"))); } } catch (Exception ex) diff --git a/shadowsocks-csharp/Controller/PACServer.cs b/shadowsocks-csharp/Controller/PACServer.cs index c2d10afd2e..d7ff3eb3cf 100755 --- a/shadowsocks-csharp/Controller/PACServer.cs +++ b/shadowsocks-csharp/Controller/PACServer.cs @@ -22,6 +22,8 @@ class PACServer : Listener.Service public static string WHITELIST_FILE = @"whitelist.txt"; + public static string USER_WHITELIST_TEMPLATE_FILE = @"user_whitelist_temp.txt"; + FileSystemWatcher PACFileWatcher; FileSystemWatcher UserRuleFileWatcher; private Configuration _config; diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index 95a4b5a9b6..97cabbfa6c 100755 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -414,9 +414,9 @@ public Configuration() dnsServer = ""; balanceAlgorithm = "LowException"; - random = true; - sysProxyMode = (int)ProxyMode.Global; - proxyRuleMode = (int)ProxyRuleMode.BypassLanAndChina; + random = false; + sysProxyMode = (int)ProxyMode.NoModify; + proxyRuleMode = (int)ProxyRuleMode.Disable; nodeFeedAutoUpdate = true;