From 7408a75f0ea0a09d884065da2d719b293bb9a6be Mon Sep 17 00:00:00 2001 From: Syrone Wong Date: Fri, 31 Mar 2017 22:04:41 +0800 Subject: [PATCH] drop OTA; add AEAD config --- .gitignore | 2 - .../Controller/ShadowsocksController.cs | 3 +- shadowsocks-csharp/Model/Server.cs | 5 +- .../View/ConfigForm.Designer.cs | 76 ++++++++----------- shadowsocks-csharp/View/ConfigForm.cs | 3 - 5 files changed, 35 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 2e8b8bf7..76aade35 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,6 @@ TestResults *.suo shadowsocks-csharp/3rd/* -!shadowsocks-csharp/3rd/zxing/ -!shadowsocks-csharp/3rd/SimpleJson.cs packages/* shadowsocks-csharp.sln.DotSettings.user diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index 9ec544d9..3f37cbf6 100644 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -303,8 +303,7 @@ namespace Shadowsocks.Controller public static string GetQRCode(Server server) { string tag = string.Empty; - string auth = server.auth ? "-auth" : string.Empty; - string parts = $"{server.method}{auth}:{server.password}@{server.server}:{server.server_port}"; + string parts = $"{server.method}:{server.password}@{server.server}:{server.server_port}"; string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(parts)); if(!server.remarks.IsNullOrEmpty()) { diff --git a/shadowsocks-csharp/Model/Server.cs b/shadowsocks-csharp/Model/Server.cs index fcdb82af..ee2ed8f8 100755 --- a/shadowsocks-csharp/Model/Server.cs +++ b/shadowsocks-csharp/Model/Server.cs @@ -11,7 +11,7 @@ namespace Shadowsocks.Model { public static readonly Regex UrlFinder = new Regex("^(?i)ss://([A-Za-z0-9+-/=_]+)(#(.+))?$", RegexOptions.IgnoreCase), - DetailsParser = new Regex("^((?.+?)(?-auth)??:(?.*)@(?.+?)" + + DetailsParser = new Regex("^((?.+?):(?.*)@(?.+?)" + ":(?\\d+?))$", RegexOptions.IgnoreCase); private const int DefaultServerTimeoutSec = 5; @@ -22,7 +22,6 @@ namespace Shadowsocks.Model public string password; public string method; public string remarks; - public bool auth; public int timeout; public override int GetHashCode() @@ -67,7 +66,6 @@ namespace Shadowsocks.Model method = "aes-256-cfb"; password = ""; remarks = ""; - auth = false; timeout = DefaultServerTimeoutSec; } @@ -82,7 +80,6 @@ namespace Shadowsocks.Model match = DetailsParser.Match(Encoding.UTF8.GetString(Convert.FromBase64String( base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '=')))); method = match.Groups["method"].Value; - auth = match.Groups["auth"].Success; password = match.Groups["password"].Value; server = match.Groups["hostname"].Value; server_port = int.Parse(match.Groups["port"].Value); diff --git a/shadowsocks-csharp/View/ConfigForm.Designer.cs b/shadowsocks-csharp/View/ConfigForm.Designer.cs index 6f546053..f389cfe2 100755 --- a/shadowsocks-csharp/View/ConfigForm.Designer.cs +++ b/shadowsocks-csharp/View/ConfigForm.Designer.cs @@ -39,7 +39,8 @@ this.PasswordTextBox = new System.Windows.Forms.TextBox(); this.EncryptionLabel = new System.Windows.Forms.Label(); this.EncryptionSelect = new System.Windows.Forms.ComboBox(); - this.OneTimeAuth = new System.Windows.Forms.CheckBox(); + this.TimeoutLabel = new System.Windows.Forms.Label(); + this.TimeoutTextBox = new System.Windows.Forms.TextBox(); this.panel2 = new System.Windows.Forms.Panel(); this.OKButton = new System.Windows.Forms.Button(); this.MyCancelButton = new System.Windows.Forms.Button(); @@ -57,8 +58,6 @@ this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); this.DuplicateButton = new System.Windows.Forms.Button(); - this.TimeoutLabel = new System.Windows.Forms.Label(); - this.TimeoutTextBox = new System.Windows.Forms.TextBox(); this.tableLayoutPanel1.SuspendLayout(); this.ServerGroupBox.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); @@ -85,15 +84,13 @@ this.tableLayoutPanel1.Controls.Add(this.PasswordTextBox, 1, 2); this.tableLayoutPanel1.Controls.Add(this.EncryptionLabel, 0, 3); this.tableLayoutPanel1.Controls.Add(this.EncryptionSelect, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.OneTimeAuth, 1, 7); this.tableLayoutPanel1.Controls.Add(this.TimeoutLabel, 0, 6); this.tableLayoutPanel1.Controls.Add(this.TimeoutTextBox, 1, 6); this.tableLayoutPanel1.Location = new System.Drawing.Point(8, 21); this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3); - this.tableLayoutPanel1.RowCount = 8; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowCount = 7; 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()); @@ -101,7 +98,7 @@ 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(255, 189); + this.tableLayoutPanel1.Size = new System.Drawing.Size(255, 167); this.tableLayoutPanel1.TabIndex = 0; // // RemarksTextBox @@ -217,21 +214,35 @@ "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", - "camellia-256-cfb"}); + "camellia-256-cfb", + "aes-128-gcm", + "aes-192-gcm", + "aes-256-gcm", + "chacha20-ietf-poly1305"}); this.EncryptionSelect.Location = new System.Drawing.Point(89, 87); this.EncryptionSelect.Name = "EncryptionSelect"; this.EncryptionSelect.Size = new System.Drawing.Size(160, 20); this.EncryptionSelect.TabIndex = 3; // - // OneTimeAuth + // TimeoutLabel + // + this.TimeoutLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.TimeoutLabel.AutoSize = true; + this.TimeoutLabel.Location = new System.Drawing.Point(6, 144); + this.TimeoutLabel.Name = "TimeoutLabel"; + this.TimeoutLabel.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.TimeoutLabel.Size = new System.Drawing.Size(77, 12); + this.TimeoutLabel.TabIndex = 10; + this.TimeoutLabel.Text = "Timeout(Sec)"; // - this.OneTimeAuth.AutoSize = true; - this.OneTimeAuth.Location = new System.Drawing.Point(89, 167); - this.OneTimeAuth.Name = "OneTimeAuth"; - this.OneTimeAuth.Size = new System.Drawing.Size(156, 16); - this.OneTimeAuth.TabIndex = 5; - this.OneTimeAuth.Text = "Onetime Authentication"; - this.OneTimeAuth.UseVisualStyleBackColor = true; + // TimeoutTextBox + // + this.TimeoutTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.TimeoutTextBox.Location = new System.Drawing.Point(89, 140); + this.TimeoutTextBox.MaxLength = 5; + this.TimeoutTextBox.Name = "TimeoutTextBox"; + this.TimeoutTextBox.Size = new System.Drawing.Size(160, 21); + this.TimeoutTextBox.TabIndex = 11; // // panel2 // @@ -301,7 +312,7 @@ this.ServerGroupBox.Location = new System.Drawing.Point(178, 0); this.ServerGroupBox.Margin = new System.Windows.Forms.Padding(12, 0, 0, 0); this.ServerGroupBox.Name = "ServerGroupBox"; - this.ServerGroupBox.Size = new System.Drawing.Size(266, 227); + this.ServerGroupBox.Size = new System.Drawing.Size(266, 205); this.ServerGroupBox.TabIndex = 0; this.ServerGroupBox.TabStop = false; this.ServerGroupBox.Text = "Server"; @@ -338,7 +349,7 @@ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel2.Size = new System.Drawing.Size(444, 323); + this.tableLayoutPanel2.Size = new System.Drawing.Size(444, 301); this.tableLayoutPanel2.TabIndex = 7; // // tableLayoutPanel6 @@ -351,7 +362,7 @@ this.tableLayoutPanel6.Controls.Add(this.MoveDownButton, 1, 0); this.tableLayoutPanel6.Controls.Add(this.MoveUpButton, 0, 0); this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Top; - this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 291); + this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 269); this.tableLayoutPanel6.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel6.Name = "tableLayoutPanel6"; this.tableLayoutPanel6.RowCount = 1; @@ -394,7 +405,7 @@ this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel5.Controls.Add(this.ProxyPortTextBox, 1, 0); this.tableLayoutPanel5.Controls.Add(this.ProxyPortLabel, 0, 0); - this.tableLayoutPanel5.Location = new System.Drawing.Point(248, 227); + this.tableLayoutPanel5.Location = new System.Drawing.Point(248, 205); this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel5.Name = "tableLayoutPanel5"; this.tableLayoutPanel5.Padding = new System.Windows.Forms.Padding(3); @@ -438,7 +449,7 @@ this.tableLayoutPanel3.Controls.Add(this.MyCancelButton, 1, 0); this.tableLayoutPanel3.Controls.Add(this.OKButton, 0, 0); this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Right; - this.tableLayoutPanel3.Location = new System.Drawing.Point(285, 294); + this.tableLayoutPanel3.Location = new System.Drawing.Point(285, 272); this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.RowCount = 1; @@ -457,7 +468,7 @@ this.tableLayoutPanel4.Controls.Add(this.DeleteButton, 1, 0); this.tableLayoutPanel4.Controls.Add(this.AddButton, 0, 0); this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Top; - this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 227); + this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 205); this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel4.Name = "tableLayoutPanel4"; this.tableLayoutPanel4.RowCount = 2; @@ -478,26 +489,6 @@ this.DuplicateButton.UseVisualStyleBackColor = true; this.DuplicateButton.Click += new System.EventHandler(this.DuplicateButton_Click); // - // TimeoutLabel - // - this.TimeoutLabel.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.TimeoutLabel.AutoSize = true; - this.TimeoutLabel.Location = new System.Drawing.Point(6, 144); - this.TimeoutLabel.Name = "TimeoutLabel"; - this.TimeoutLabel.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.TimeoutLabel.Size = new System.Drawing.Size(77, 12); - this.TimeoutLabel.TabIndex = 10; - this.TimeoutLabel.Text = "Timeout(Sec)"; - // - // TimeoutTextBox - // - this.TimeoutTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.TimeoutTextBox.Location = new System.Drawing.Point(89, 140); - this.TimeoutTextBox.MaxLength = 5; - this.TimeoutTextBox.Name = "TimeoutTextBox"; - this.TimeoutTextBox.Size = new System.Drawing.Size(160, 21); - this.TimeoutTextBox.TabIndex = 11; - // // ConfigForm // this.AcceptButton = this.OKButton; @@ -565,7 +556,6 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; private System.Windows.Forms.Button MoveDownButton; private System.Windows.Forms.Button MoveUpButton; - private System.Windows.Forms.CheckBox OneTimeAuth; private System.Windows.Forms.Button DuplicateButton; private System.Windows.Forms.Label TimeoutLabel; private System.Windows.Forms.TextBox TimeoutTextBox; diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index 9c0ac555..f1f5f092 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -50,7 +50,6 @@ namespace Shadowsocks.View ProxyPortLabel.Text = I18N.GetString("Proxy Port"); RemarksLabel.Text = I18N.GetString("Remarks"); TimeoutLabel.Text = I18N.GetString("Timeout(Sec)"); - OneTimeAuth.Text = I18N.GetString("Onetime Authentication"); ServerGroupBox.Text = I18N.GetString("Server"); OKButton.Text = I18N.GetString("OK"); MyCancelButton.Text = I18N.GetString("Cancel"); @@ -102,7 +101,6 @@ namespace Shadowsocks.View TimeoutTextBox.Focus(); return false; } - server.auth = OneTimeAuth.Checked; int localPort = int.Parse(ProxyPortTextBox.Text); Configuration.CheckServer(server); Configuration.CheckLocalPort(localPort); @@ -131,7 +129,6 @@ namespace Shadowsocks.View EncryptionSelect.Text = server.method ?? "aes-256-cfb"; RemarksTextBox.Text = server.remarks; TimeoutTextBox.Text = server.timeout.ToString(); - OneTimeAuth.Checked = server.auth; } }