Browse Source

lint code

tags/2.3
clowwindy 9 years ago
parent
commit
b9b9202cde
3 changed files with 8 additions and 12 deletions
  1. +6
    -10
      shadowsocks-csharp/Controller/GfwListUpdater.cs
  2. +1
    -0
      shadowsocks-csharp/Controller/UpdateChecker.cs
  3. +1
    -2
      shadowsocks-csharp/View/MenuViewController.cs

+ 6
- 10
shadowsocks-csharp/Controller/GfwListUpdater.cs View File

@@ -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<string> 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<string> 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;
}
}
}
}

+ 1
- 0
shadowsocks-csharp/Controller/UpdateChecker.cs View File

@@ -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));
}


+ 1
- 2
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -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());


Loading…
Cancel
Save