Skip to content

Commit

Permalink
增加自定义白名单模版"user_whitelist_temp.txt"
Browse files Browse the repository at this point in the history
修改默认设置:
关闭均衡负载
代理规则:全局
系统代理模式:不修改
  • Loading branch information
HMBSbige committed May 2, 2018
1 parent 7905dc7 commit 6b64937
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
22 changes: 20 additions & 2 deletions shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions shadowsocks-csharp/Controller/PACServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6b64937

Please sign in to comment.