Compare commits

...
3 Commits
Author SHA1 Message Date
clowwindy 9a4f724653 bump 2.3.1 2015-03-06 23:21:56 +08:00
clowwindy fcb0adfc3f add comments in cn.txt 2015-03-06 23:18:23 +08:00
clowwindy eb2e5cc242 add GUI for user rule support 2015-03-06 23:02:07 +08:00
10 changed files with 74 additions and 10 deletions
+4
View File
@@ -18,6 +18,10 @@ namespace Shadowsocks.Controller
string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n"); string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n");
foreach (string line in lines) foreach (string line in lines)
{ {
if (line.StartsWith("#"))
{
continue;
}
string[] kv = Regex.Split(line, "="); string[] kv = Regex.Split(line, "=");
if (kv.Length == 2) if (kv.Length == 2)
{ {
@@ -96,6 +96,19 @@ namespace Shadowsocks.Controller
} }
} }
internal string TouchUserRuleFile()
{
if (File.Exists(USER_RULE_FILE))
{
return USER_RULE_FILE;
}
else
{
File.WriteAllText(USER_RULE_FILE, Resources.user_rule);
return USER_RULE_FILE;
}
}
private string GetPACContent() private string GetPACContent()
{ {
if (File.Exists(PAC_FILE)) if (File.Exists(PAC_FILE))
@@ -38,6 +38,7 @@ namespace Shadowsocks.Controller
// when user clicked Edit PAC, and PAC file has already created // when user clicked Edit PAC, and PAC file has already created
public event EventHandler<PathEventArgs> PACFileReadyToOpen; public event EventHandler<PathEventArgs> PACFileReadyToOpen;
public event EventHandler<PathEventArgs> UserRuleFileReadyToOpen;
public event EventHandler<GFWListUpdater.ResultEventArgs> UpdatePACFromGFWListCompleted; public event EventHandler<GFWListUpdater.ResultEventArgs> UpdatePACFromGFWListCompleted;
@@ -166,6 +167,15 @@ namespace Shadowsocks.Controller
} }
} }
public void TouchUserRuleFile()
{
string userRuleFilename = _pacServer.TouchUserRuleFile();
if (UserRuleFileReadyToOpen != null)
{
UserRuleFileReadyToOpen(this, new PathEventArgs() { Path = userRuleFilename });
}
}
public string GetQRCodeForCurrentServer() public string GetQRCodeForCurrentServer()
{ {
Server server = GetCurrentServer(); Server server = GetCurrentServer();
@@ -18,7 +18,7 @@ namespace Shadowsocks.Controller
public string LatestVersionURL; public string LatestVersionURL;
public event EventHandler NewVersionFound; public event EventHandler NewVersionFound;
public const string Version = "2.3"; public const string Version = "2.3.1";
public void CheckUpdate(Configuration config) public void CheckUpdate(Configuration config)
{ {
+15
View File
@@ -1,4 +1,9 @@
# translation for Simplified Chinese
Shadowsocks=Shadowsocks Shadowsocks=Shadowsocks
# Menu items
Enable System Proxy=启用系统代理 Enable System Proxy=启用系统代理
Mode=系统代理模式 Mode=系统代理模式
PAC=PAC 模式 PAC=PAC 模式
@@ -8,12 +13,16 @@ Edit Servers...=编辑服务器...
Start on Boot=开机启动 Start on Boot=开机启动
Allow Clients from LAN=允许来自局域网的连接 Allow Clients from LAN=允许来自局域网的连接
Edit PAC File...=编辑 PAC 文件... Edit PAC File...=编辑 PAC 文件...
Edit User Rule for GFWList...=编辑 GFWList 的用户规则...
Show QRCode...=显示二维码... Show QRCode...=显示二维码...
Scan QRCode from Screen...=扫描屏幕上的二维码... Scan QRCode from Screen...=扫描屏幕上的二维码...
Show Logs...=显示日志... Show Logs...=显示日志...
About...=关于... About...=关于...
Quit=退出 Quit=退出
Edit Servers=编辑服务器 Edit Servers=编辑服务器
# Config Form
&Add=添加(&A) &Add=添加(&A)
&Delete=删除(&D) &Delete=删除(&D)
Server=服务器 Server=服务器
@@ -26,7 +35,13 @@ Remarks=备注
OK=确定 OK=确定
Cancel=取消 Cancel=取消
New server=未配置的服务器 New server=未配置的服务器
# QRCode Form
QRCode=二维码 QRCode=二维码
# Messages
Shadowsocks Error: {0}=Shadowsocks 错误: {0} Shadowsocks Error: {0}=Shadowsocks 错误: {0}
Port already in use=端口已被占用 Port already in use=端口已被占用
Illegal port number format=非法端口格式 Illegal port number format=非法端口格式
+2
View File
@@ -0,0 +1,2 @@
! Put user rules line by line in this file.
! See https://adblockplus.org/en/filter-cheatsheet
+13 -5
View File
@@ -81,6 +81,7 @@ namespace Shadowsocks.Properties {
///Start on Boot=开机启动 ///Start on Boot=开机启动
///Allow Clients from LAN=允许来自局域网的连接 ///Allow Clients from LAN=允许来自局域网的连接
///Edit PAC File...=编辑 PAC 文件... ///Edit PAC File...=编辑 PAC 文件...
///Edit User Rule for GFWList...=编辑 GFWList 的用户规则...
///Show QRCode...=显示二维码... ///Show QRCode...=显示二维码...
///Scan QRCode from Screen...=扫描屏幕上的二维码... ///Scan QRCode from Screen...=扫描屏幕上的二维码...
///Show Logs...=显示日志... ///Show Logs...=显示日志...
@@ -96,11 +97,7 @@ namespace Shadowsocks.Properties {
///Encryption=加密 ///Encryption=加密
///Proxy Port=代理端口 ///Proxy Port=代理端口
///Remarks=备注 ///Remarks=备注
///OK=确定 ///OK= [rest of string was truncated]&quot;;.
///Cancel=取消
///New server=未配置的服务器
///QRCode=二维码
///Shadows [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string cn { internal static string cn {
get { get {
@@ -195,5 +192,16 @@ namespace Shadowsocks.Properties {
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
/// <summary>
/// Looks up a localized string similar to ! Put user rules line by line in this file.
///! See https://adblockplus.org/en/filter-cheatsheet
///.
/// </summary>
internal static string user_rule {
get {
return ResourceManager.GetString("user_rule", resourceCulture);
}
}
} }
} }
@@ -148,4 +148,7 @@
<data name="ssw128" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="ssw128" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ssw128.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\ssw128.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="user_rule" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\user-rule.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root> </root>
+12 -4
View File
@@ -46,7 +46,8 @@ namespace Shadowsocks.View
controller.EnableStatusChanged += controller_EnableStatusChanged; controller.EnableStatusChanged += controller_EnableStatusChanged;
controller.ConfigChanged += controller_ConfigChanged; controller.ConfigChanged += controller_ConfigChanged;
controller.PACFileReadyToOpen += controller_PACFileReadyToOpen; controller.PACFileReadyToOpen += controller_FileReadyToOpen;
controller.UserRuleFileReadyToOpen += controller_FileReadyToOpen;
controller.ShareOverLANStatusChanged += controller_ShareOverLANStatusChanged; controller.ShareOverLANStatusChanged += controller_ShareOverLANStatusChanged;
controller.EnableGlobalChanged += controller_EnableGlobalChanged; controller.EnableGlobalChanged += controller_EnableGlobalChanged;
controller.Errored += controller_Errored; controller.Errored += controller_Errored;
@@ -151,10 +152,12 @@ namespace Shadowsocks.View
CreateMenuItem("Scan QRCode from Screen...", new EventHandler(this.ScanQRCodeItem_Click)) CreateMenuItem("Scan QRCode from Screen...", new EventHandler(this.ScanQRCodeItem_Click))
}), }),
new MenuItem("-"), new MenuItem("-"),
this.AutoStartupItem = CreateMenuItem("Start on Boot", new EventHandler(this.AutoStartupItem_Click)),
this.ShareOverLANItem = CreateMenuItem("Allow Clients from LAN", new EventHandler(this.ShareOverLANItem_Click)),
CreateMenuItem("Edit PAC File...", new EventHandler(this.EditPACFileItem_Click)), CreateMenuItem("Edit PAC File...", new EventHandler(this.EditPACFileItem_Click)),
CreateMenuItem("Update PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)), CreateMenuItem("Update PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)),
CreateMenuItem("Edit User Rule for GFWList...", new EventHandler(this.EditUserRuleFileForGFWListItem_Click)),
new MenuItem("-"),
this.AutoStartupItem = CreateMenuItem("Start on Boot", new EventHandler(this.AutoStartupItem_Click)),
this.ShareOverLANItem = CreateMenuItem("Allow Clients from LAN", new EventHandler(this.ShareOverLANItem_Click)),
new MenuItem("-"), new MenuItem("-"),
CreateMenuItem("Show Logs...", new EventHandler(this.ShowLogItem_Click)), CreateMenuItem("Show Logs...", new EventHandler(this.ShowLogItem_Click)),
CreateMenuItem("About...", new EventHandler(this.AboutItem_Click)), CreateMenuItem("About...", new EventHandler(this.AboutItem_Click)),
@@ -186,7 +189,7 @@ namespace Shadowsocks.View
PACModeItem.Checked = !globalModeItem.Checked; PACModeItem.Checked = !globalModeItem.Checked;
} }
void controller_PACFileReadyToOpen(object sender, ShadowsocksController.PathEventArgs e) void controller_FileReadyToOpen(object sender, ShadowsocksController.PathEventArgs e)
{ {
string argument = @"/select, " + e.Path; string argument = @"/select, " + e.Path;
@@ -352,6 +355,11 @@ namespace Shadowsocks.View
controller.UpdatePACFromGFWList(); controller.UpdatePACFromGFWList();
} }
private void EditUserRuleFileForGFWListItem_Click(object sender, EventArgs e)
{
controller.TouchUserRuleFile();
}
private void AServerItem_Click(object sender, EventArgs e) private void AServerItem_Click(object sender, EventArgs e)
{ {
MenuItem item = (MenuItem)sender; MenuItem item = (MenuItem)sender;
@@ -198,6 +198,7 @@
<None Include="Resources\ss24.png" /> <None Include="Resources\ss24.png" />
<None Include="Resources\ssw128.png" /> <None Include="Resources\ssw128.png" />
<Content Include="Data\cn.txt" /> <Content Include="Data\cn.txt" />
<Content Include="Data\user-rule.txt" />
<Content Include="shadowsocks.ico" /> <Content Include="shadowsocks.ico" />
<None Include="Data\polipo_config.txt" /> <None Include="Data\polipo_config.txt" />
</ItemGroup> </ItemGroup>