diff --git a/shadowsocks-csharp/Controller/GfwListUpdater.cs b/shadowsocks-csharp/Controller/GfwListUpdater.cs index fded3a59..7abe9445 100644 --- a/shadowsocks-csharp/Controller/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/GfwListUpdater.cs @@ -4,8 +4,6 @@ using System.Text; using System.Net; using System.IO; using Shadowsocks.Properties; -using System.IO.Compression; -using System.Text.RegularExpressions; using SimpleJson; using Shadowsocks.Util; @@ -25,12 +23,10 @@ namespace Shadowsocks.Controller { try { - string[] lines = ParseResult(e.Result); + List lines = ParseResult(e.Result); - JsonArray rules = new JsonArray(); - rules.AddRange(lines); string abpContent = Utils.UnGzip(Resources.abp_js); - abpContent = abpContent.Replace("__RULES__", rules.ToString()); + abpContent = abpContent.Replace("__RULES__", SimpleJson.SimpleJson.SerializeObject(lines)); File.WriteAllText(PAC_FILE, abpContent, Encoding.UTF8); if (UpdateCompleted != null) { @@ -46,15 +42,15 @@ namespace Shadowsocks.Controller } } - public void UpdatePACFromGFWList() { WebClient http = new WebClient(); + http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), 8123); http.DownloadStringCompleted += http_DownloadStringCompleted; http.DownloadStringAsync(new Uri(GFWLIST_URL)); } - public string[] ParseResult(string response) + public List ParseResult(string response) { byte[] bytes = Convert.FromBase64String(response); string content = Encoding.ASCII.GetString(bytes); @@ -66,7 +62,7 @@ namespace Shadowsocks.Controller continue; valid_lines.Add(line); } - return valid_lines.ToArray(); + return valid_lines; } } -} +} \ No newline at end of file diff --git a/shadowsocks-csharp/Controller/UpdateChecker.cs b/shadowsocks-csharp/Controller/UpdateChecker.cs index d6653468..7996a687 100755 --- a/shadowsocks-csharp/Controller/UpdateChecker.cs +++ b/shadowsocks-csharp/Controller/UpdateChecker.cs @@ -23,6 +23,7 @@ namespace Shadowsocks.Controller { // TODO test failures WebClient http = new WebClient(); + http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), 8123); http.DownloadStringCompleted += http_DownloadStringCompleted; http.DownloadStringAsync(new Uri(UpdateURL)); } diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 76da6036..3d875f3e 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.IO; using System.Text; using System.Windows.Forms; @@ -188,7 +187,7 @@ namespace Shadowsocks.View _notifyIcon.ShowBalloonTip(timeout); } - void controller_UpdatePACFromGFWListError(object sender, ErrorEventArgs e) + void controller_UpdatePACFromGFWListError(object sender, System.IO.ErrorEventArgs e) { ShowBalloonTip(I18N.GetString("Failed to update PAC file"), e.GetException().Message, ToolTipIcon.Error, 5000); Logging.LogUsefulException(e.GetException());