Merge pull request #21
This commit is contained in:
@@ -37,6 +37,7 @@ namespace Shadowsocks.Model
|
||||
checkPort(server.server_port);
|
||||
checkPassword(server.password);
|
||||
checkServer(server.server);
|
||||
checkRemark(server.remark);
|
||||
}
|
||||
|
||||
public static Configuration Load()
|
||||
@@ -100,7 +101,8 @@ namespace Shadowsocks.Model
|
||||
server_port = 8388,
|
||||
local_port = 1080,
|
||||
method = "aes-256-cfb",
|
||||
password = ""
|
||||
password = "",
|
||||
remark = ""
|
||||
};
|
||||
}
|
||||
|
||||
@@ -136,6 +138,11 @@ namespace Shadowsocks.Model
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkRemark(string remark)
|
||||
{
|
||||
//remark is optional
|
||||
}
|
||||
|
||||
private class JsonSerializerStrategy : SimpleJson.PocoJsonSerializerStrategy
|
||||
{
|
||||
// convert string to int
|
||||
|
||||
@@ -15,6 +15,6 @@ namespace Shadowsocks.Model
|
||||
public int local_port;
|
||||
public string password;
|
||||
public string method;
|
||||
|
||||
public string remark;
|
||||
}
|
||||
}
|
||||
|
||||
+61
-34
@@ -61,6 +61,8 @@
|
||||
this.AddButton = new System.Windows.Forms.Button();
|
||||
this.ServerGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ServersListBox = new System.Windows.Forms.ListBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
@@ -74,6 +76,8 @@
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.Controls.Add(this.RemarkTextBox, 1, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label6, 0, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.ProxyPortTextBox, 1, 4);
|
||||
@@ -84,26 +88,27 @@
|
||||
this.tableLayoutPanel1.Controls.Add(this.PasswordTextBox, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label5, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.EncryptionSelect, 1, 3);
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(8, 21);
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(8, 20);
|
||||
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(5);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.tableLayoutPanel1.RowCount = 5;
|
||||
this.tableLayoutPanel1.RowCount = 6;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(242, 141);
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(253, 171);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(17, 11);
|
||||
this.label1.Location = new System.Drawing.Point(20, 12);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(51, 13);
|
||||
this.label1.Size = new System.Drawing.Size(59, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Server IP";
|
||||
//
|
||||
@@ -111,18 +116,18 @@
|
||||
//
|
||||
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(8, 37);
|
||||
this.label2.Location = new System.Drawing.Point(8, 39);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(60, 13);
|
||||
this.label2.Size = new System.Drawing.Size(71, 12);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Server Port";
|
||||
//
|
||||
// ProxyPortTextBox
|
||||
//
|
||||
this.ProxyPortTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ProxyPortTextBox.Location = new System.Drawing.Point(74, 113);
|
||||
this.ProxyPortTextBox.Location = new System.Drawing.Point(85, 115);
|
||||
this.ProxyPortTextBox.Name = "ProxyPortTextBox";
|
||||
this.ProxyPortTextBox.Size = new System.Drawing.Size(160, 20);
|
||||
this.ProxyPortTextBox.Size = new System.Drawing.Size(160, 21);
|
||||
this.ProxyPortTextBox.TabIndex = 4;
|
||||
this.ProxyPortTextBox.WordWrap = false;
|
||||
//
|
||||
@@ -130,9 +135,9 @@
|
||||
//
|
||||
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(13, 116);
|
||||
this.label4.Location = new System.Drawing.Point(14, 119);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(55, 13);
|
||||
this.label4.Size = new System.Drawing.Size(65, 12);
|
||||
this.label4.TabIndex = 3;
|
||||
this.label4.Text = "Proxy Port";
|
||||
//
|
||||
@@ -140,37 +145,37 @@
|
||||
//
|
||||
this.label3.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(15, 63);
|
||||
this.label3.Location = new System.Drawing.Point(26, 66);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 13);
|
||||
this.label3.Size = new System.Drawing.Size(53, 12);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "Password";
|
||||
//
|
||||
// IPTextBox
|
||||
//
|
||||
this.IPTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.IPTextBox.Location = new System.Drawing.Point(74, 8);
|
||||
this.IPTextBox.Location = new System.Drawing.Point(85, 8);
|
||||
this.IPTextBox.Name = "IPTextBox";
|
||||
this.IPTextBox.Size = new System.Drawing.Size(160, 20);
|
||||
this.IPTextBox.Size = new System.Drawing.Size(160, 21);
|
||||
this.IPTextBox.TabIndex = 0;
|
||||
this.IPTextBox.WordWrap = false;
|
||||
//
|
||||
// ServerPortTextBox
|
||||
//
|
||||
this.ServerPortTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ServerPortTextBox.Location = new System.Drawing.Point(74, 34);
|
||||
this.ServerPortTextBox.Location = new System.Drawing.Point(85, 35);
|
||||
this.ServerPortTextBox.Name = "ServerPortTextBox";
|
||||
this.ServerPortTextBox.Size = new System.Drawing.Size(160, 20);
|
||||
this.ServerPortTextBox.Size = new System.Drawing.Size(160, 21);
|
||||
this.ServerPortTextBox.TabIndex = 1;
|
||||
this.ServerPortTextBox.WordWrap = false;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(74, 60);
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(85, 62);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.PasswordChar = '*';
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(160, 20);
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(160, 21);
|
||||
this.PasswordTextBox.TabIndex = 2;
|
||||
this.PasswordTextBox.WordWrap = false;
|
||||
//
|
||||
@@ -178,9 +183,9 @@
|
||||
//
|
||||
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(11, 90);
|
||||
this.label5.Location = new System.Drawing.Point(14, 93);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(57, 13);
|
||||
this.label5.Size = new System.Drawing.Size(65, 12);
|
||||
this.label5.TabIndex = 8;
|
||||
this.label5.Text = "Encryption";
|
||||
//
|
||||
@@ -191,7 +196,7 @@
|
||||
this.EncryptionSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.EncryptionSelect.FormattingEnabled = true;
|
||||
this.EncryptionSelect.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.EncryptionSelect.ItemHeight = 13;
|
||||
this.EncryptionSelect.ItemHeight = 12;
|
||||
this.EncryptionSelect.Items.AddRange(new object[] {
|
||||
"table",
|
||||
"rc4-md5",
|
||||
@@ -200,9 +205,9 @@
|
||||
"aes-128-cfb",
|
||||
"bf-cfb",
|
||||
"rc4"});
|
||||
this.EncryptionSelect.Location = new System.Drawing.Point(74, 86);
|
||||
this.EncryptionSelect.Location = new System.Drawing.Point(85, 89);
|
||||
this.EncryptionSelect.Name = "EncryptionSelect";
|
||||
this.EncryptionSelect.Size = new System.Drawing.Size(160, 21);
|
||||
this.EncryptionSelect.Size = new System.Drawing.Size(160, 20);
|
||||
this.EncryptionSelect.TabIndex = 3;
|
||||
//
|
||||
// notifyIcon1
|
||||
@@ -217,7 +222,7 @@
|
||||
this.panel2.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.panel2.AutoSize = true;
|
||||
this.panel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.panel2.Location = new System.Drawing.Point(142, 175);
|
||||
this.panel2.Location = new System.Drawing.Point(164, 175);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(0, 0);
|
||||
this.panel2.TabIndex = 1;
|
||||
@@ -325,17 +330,17 @@
|
||||
this.panel3.AutoSize = true;
|
||||
this.panel3.Controls.Add(this.DeleteButton);
|
||||
this.panel3.Controls.Add(this.AddButton);
|
||||
this.panel3.Location = new System.Drawing.Point(12, 207);
|
||||
this.panel3.Location = new System.Drawing.Point(12, 220);
|
||||
this.panel3.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Size = new System.Drawing.Size(164, 30);
|
||||
this.panel3.Size = new System.Drawing.Size(192, 30);
|
||||
this.panel3.TabIndex = 5;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
this.DeleteButton.Location = new System.Drawing.Point(86, 4);
|
||||
this.DeleteButton.Location = new System.Drawing.Point(100, 4);
|
||||
this.DeleteButton.Name = "DeleteButton";
|
||||
this.DeleteButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.DeleteButton.Size = new System.Drawing.Size(89, 23);
|
||||
this.DeleteButton.TabIndex = 7;
|
||||
this.DeleteButton.Text = "&Delete";
|
||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||
@@ -345,7 +350,7 @@
|
||||
//
|
||||
this.AddButton.Location = new System.Drawing.Point(4, 4);
|
||||
this.AddButton.Name = "AddButton";
|
||||
this.AddButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.AddButton.Size = new System.Drawing.Size(89, 23);
|
||||
this.AddButton.TabIndex = 6;
|
||||
this.AddButton.Text = "&Add";
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
@@ -354,9 +359,9 @@
|
||||
// ServerGroupBox
|
||||
//
|
||||
this.ServerGroupBox.Controls.Add(this.tableLayoutPanel1);
|
||||
this.ServerGroupBox.Location = new System.Drawing.Point(182, 12);
|
||||
this.ServerGroupBox.Location = new System.Drawing.Point(210, 12);
|
||||
this.ServerGroupBox.Name = "ServerGroupBox";
|
||||
this.ServerGroupBox.Size = new System.Drawing.Size(257, 186);
|
||||
this.ServerGroupBox.Size = new System.Drawing.Size(270, 205);
|
||||
this.ServerGroupBox.TabIndex = 6;
|
||||
this.ServerGroupBox.TabStop = false;
|
||||
this.ServerGroupBox.Text = "Server";
|
||||
@@ -364,19 +369,39 @@
|
||||
// ServersListBox
|
||||
//
|
||||
this.ServersListBox.FormattingEnabled = true;
|
||||
this.ServersListBox.ItemHeight = 12;
|
||||
this.ServersListBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ServersListBox.Name = "ServersListBox";
|
||||
this.ServersListBox.Size = new System.Drawing.Size(164, 186);
|
||||
this.ServersListBox.Size = new System.Drawing.Size(192, 196);
|
||||
this.ServersListBox.TabIndex = 5;
|
||||
this.ServersListBox.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged);
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(38, 146);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(41, 12);
|
||||
this.label6.TabIndex = 9;
|
||||
this.label6.Text = "Remark";
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(85, 142);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(160, 21);
|
||||
this.RemarkTextBox.TabIndex = 10;
|
||||
this.RemarkTextBox.WordWrap = false;
|
||||
//
|
||||
// ConfigForm
|
||||
//
|
||||
this.AcceptButton = this.OKButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.AutoSize = true;
|
||||
this.ClientSize = new System.Drawing.Size(445, 286);
|
||||
this.ClientSize = new System.Drawing.Size(489, 286);
|
||||
this.Controls.Add(this.ServersListBox);
|
||||
this.Controls.Add(this.ServerGroupBox);
|
||||
this.Controls.Add(this.panel1);
|
||||
@@ -435,6 +460,8 @@
|
||||
private System.Windows.Forms.MenuItem ServersItem;
|
||||
private System.Windows.Forms.MenuItem SeperatorItem;
|
||||
private System.Windows.Forms.MenuItem menuItem4;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label label6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace Shadowsocks.View
|
||||
server_port = int.Parse(ServerPortTextBox.Text),
|
||||
password = PasswordTextBox.Text,
|
||||
local_port = int.Parse(ProxyPortTextBox.Text),
|
||||
method = EncryptionSelect.Text
|
||||
method = EncryptionSelect.Text,
|
||||
remark = RemarkTextBox.Text
|
||||
};
|
||||
Configuration.CheckServer(server);
|
||||
modifiedConfiguration.configs[oldSelectedIndex] = server;
|
||||
@@ -99,6 +100,7 @@ namespace Shadowsocks.View
|
||||
PasswordTextBox.Text = server.password;
|
||||
ProxyPortTextBox.Text = server.local_port.ToString();
|
||||
EncryptionSelect.Text = server.method == null ? "aes-256-cfb" : server.method;
|
||||
RemarkTextBox.Text = server.remark;
|
||||
ServerGroupBox.Visible = true;
|
||||
IPTextBox.Focus();
|
||||
}
|
||||
@@ -113,7 +115,7 @@ namespace Shadowsocks.View
|
||||
ServersListBox.Items.Clear();
|
||||
foreach (Server server in modifiedConfiguration.configs)
|
||||
{
|
||||
ServersListBox.Items.Add(string.IsNullOrEmpty(server.server) ? "New server" : server.server + ":" + server.server_port);
|
||||
ServersListBox.Items.Add(string.IsNullOrEmpty(server.server) ? "New server" : string.IsNullOrEmpty(server.remark)? server.server + ":" + server.server_port : server.server + ":" + server.server_port + " (" + server.remark + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ namespace Shadowsocks.View
|
||||
for (int i = 0; i < configuration.configs.Count; i++)
|
||||
{
|
||||
Server server = configuration.configs[i];
|
||||
MenuItem item = new MenuItem(server.server + ":" + server.server_port);
|
||||
MenuItem item = new MenuItem(string.IsNullOrEmpty(server.remark) ? server.server + ":" + server.server_port : server.server + ":" + server.server_port + " (" + server.remark + ")");
|
||||
item.Tag = i;
|
||||
item.Click += AServerItem_Click;
|
||||
items.Add(item);
|
||||
|
||||
Reference in New Issue
Block a user