From 28887b9896a893fed543294482432cab7def7ed1 Mon Sep 17 00:00:00 2001 From: Siuzuk Zan Date: Wed, 4 Mar 2015 18:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BD=BF=E7=94=A8user-rule.txt=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shadowsocks-csharp/Controller/GfwListUpdater.cs | 14 +++++++++++++- shadowsocks-csharp/Controller/PACServer.cs | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/shadowsocks-csharp/Controller/GfwListUpdater.cs b/shadowsocks-csharp/Controller/GfwListUpdater.cs index 4cf77293..70720fb9 100644 --- a/shadowsocks-csharp/Controller/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/GfwListUpdater.cs @@ -16,6 +16,8 @@ namespace Shadowsocks.Controller private static string PAC_FILE = PACServer.PAC_FILE; + private static string USER_RULE_FILE = PACServer.USER_RULE_FILE; + public event EventHandler UpdateCompleted; public event ErrorEventHandler Error; @@ -35,7 +37,17 @@ namespace Shadowsocks.Controller try { List lines = ParseResult(e.Result); - + if (File.Exists(USER_RULE_FILE)) + { + string local = File.ReadAllText(USER_RULE_FILE, Encoding.UTF8); + string[] rules = local.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + foreach(string rule in rules) + { + if (rule.StartsWith("!") || rule.StartsWith("[")) + continue; + lines.Add(rule); + } + } string abpContent = Utils.UnGzip(Resources.abp_js); abpContent = abpContent.Replace("__RULES__", SimpleJson.SimpleJson.SerializeObject(lines)); if (File.Exists(PAC_FILE)) diff --git a/shadowsocks-csharp/Controller/PACServer.cs b/shadowsocks-csharp/Controller/PACServer.cs index 9d5e345e..934a7855 100755 --- a/shadowsocks-csharp/Controller/PACServer.cs +++ b/shadowsocks-csharp/Controller/PACServer.cs @@ -16,6 +16,8 @@ namespace Shadowsocks.Controller { public static string PAC_FILE = "pac.txt"; + public static string USER_RULE_FILE = "user-rule.txt"; + FileSystemWatcher watcher; private Configuration _config;