From c539e027d7b49e11150ccf1636722b71a3b195d2 Mon Sep 17 00:00:00 2001 From: Gang Zhuo Date: Wed, 16 Dec 2015 23:35:53 +0800 Subject: [PATCH] support custom abp file --- .../Controller/Service/GfwListUpdater.cs | 12 +++++++++++- shadowsocks-csharp/Controller/Service/PACServer.cs | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs index 493defa4..0185cc28 100644 --- a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs @@ -18,6 +18,8 @@ namespace Shadowsocks.Controller private static string USER_RULE_FILE = PACServer.USER_RULE_FILE; + private static string USER_ABP_FILE = PACServer.USER_ABP_FILE; + public event EventHandler UpdateCompleted; public event ErrorEventHandler Error; @@ -48,7 +50,15 @@ namespace Shadowsocks.Controller lines.Add(rule); } } - string abpContent = Utils.UnGzip(Resources.abp_js); + string abpContent; + if (File.Exists(USER_ABP_FILE)) + { + abpContent = File.ReadAllText(USER_ABP_FILE, Encoding.UTF8); + } + else + { + 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/Service/PACServer.cs b/shadowsocks-csharp/Controller/Service/PACServer.cs index f8fc80e8..e2d23658 100644 --- a/shadowsocks-csharp/Controller/Service/PACServer.cs +++ b/shadowsocks-csharp/Controller/Service/PACServer.cs @@ -18,6 +18,8 @@ namespace Shadowsocks.Controller public static string USER_RULE_FILE = "user-rule.txt"; + public static string USER_ABP_FILE = "abp.txt"; + FileSystemWatcher watcher; private Configuration _config;