diff --git a/Netch/Controllers/MainController.cs b/Netch/Controllers/MainController.cs index e95831c6..e1b32c77 100644 --- a/Netch/Controllers/MainController.cs +++ b/Netch/Controllers/MainController.cs @@ -124,11 +124,11 @@ namespace Netch.Controllers } // 进程代理模式,启动 NF 控制器 result = pNFController.Start(server, mode); - - Task.Run(() => - { - pNTTController.Start(); - }); + if (result) + Task.Run(() => + { + pNTTController.Start(); + }); } else if (mode.Type == 1) @@ -143,11 +143,11 @@ namespace Netch.Controllers } // TUN/TAP 黑名单代理模式,启动 TUN/TAP 控制器 result = pTUNTAPController.Start(server, mode); - - Task.Run(() => - { - pNTTController.Start(); - }); + if (result) + Task.Run(() => + { + pNTTController.Start(); + }); } else if (mode.Type == 2) { @@ -161,11 +161,11 @@ namespace Netch.Controllers } // TUN/TAP 白名单代理模式,启动 TUN/TAP 控制器 result = pTUNTAPController.Start(server, mode); - - Task.Run(() => - { - pNTTController.Start(); - }); + if (result) + Task.Run(() => + { + pNTTController.Start(); + }); } else if (mode.Type == 3 || mode.Type == 5) { diff --git a/Netch/Forms/MainForm.Designer.cs b/Netch/Forms/MainForm.Designer.cs index e5b21fdf..e99efe77 100644 --- a/Netch/Forms/MainForm.Designer.cs +++ b/Netch/Forms/MainForm.Designer.cs @@ -112,7 +112,7 @@ namespace Netch.Forms this.MenuStrip.Location = new System.Drawing.Point(0, 0); this.MenuStrip.Name = "MenuStrip"; this.MenuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.MenuStrip.Size = new System.Drawing.Size(629, 24); + this.MenuStrip.Size = new System.Drawing.Size(629, 26); this.MenuStrip.TabIndex = 0; // // ServerToolStripMenuItem @@ -125,41 +125,41 @@ namespace Netch.Forms this.AddVMessServerToolStripMenuItem}); this.ServerToolStripMenuItem.Margin = new System.Windows.Forms.Padding(3, 0, 0, 1); this.ServerToolStripMenuItem.Name = "ServerToolStripMenuItem"; - this.ServerToolStripMenuItem.Size = new System.Drawing.Size(51, 19); + this.ServerToolStripMenuItem.Size = new System.Drawing.Size(57, 21); this.ServerToolStripMenuItem.Text = "Server"; // // ImportServersFromClipboardToolStripMenuItem // this.ImportServersFromClipboardToolStripMenuItem.Name = "ImportServersFromClipboardToolStripMenuItem"; - this.ImportServersFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(236, 22); + this.ImportServersFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(259, 22); this.ImportServersFromClipboardToolStripMenuItem.Text = "Import Servers From Clipboard"; this.ImportServersFromClipboardToolStripMenuItem.Click += new System.EventHandler(this.ImportServersFromClipboardToolStripMenuItem_Click); // // AddSocks5ServerToolStripMenuItem // this.AddSocks5ServerToolStripMenuItem.Name = "AddSocks5ServerToolStripMenuItem"; - this.AddSocks5ServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22); + this.AddSocks5ServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22); this.AddSocks5ServerToolStripMenuItem.Text = "Add [Socks5] Server"; this.AddSocks5ServerToolStripMenuItem.Click += new System.EventHandler(this.AddSocks5ServerToolStripMenuItem_Click); // // AddShadowsocksServerToolStripMenuItem // this.AddShadowsocksServerToolStripMenuItem.Name = "AddShadowsocksServerToolStripMenuItem"; - this.AddShadowsocksServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22); + this.AddShadowsocksServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22); this.AddShadowsocksServerToolStripMenuItem.Text = "Add [Shadowsocks] Server"; this.AddShadowsocksServerToolStripMenuItem.Click += new System.EventHandler(this.AddShadowsocksServerToolStripMenuItem_Click); // // AddShadowsocksRServerToolStripMenuItem // this.AddShadowsocksRServerToolStripMenuItem.Name = "AddShadowsocksRServerToolStripMenuItem"; - this.AddShadowsocksRServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22); + this.AddShadowsocksRServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22); this.AddShadowsocksRServerToolStripMenuItem.Text = "Add [ShadowsocksR] Server"; this.AddShadowsocksRServerToolStripMenuItem.Click += new System.EventHandler(this.AddShadowsocksRServerToolStripMenuItem_Click); // // AddVMessServerToolStripMenuItem // this.AddVMessServerToolStripMenuItem.Name = "AddVMessServerToolStripMenuItem"; - this.AddVMessServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22); + this.AddVMessServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22); this.AddVMessServerToolStripMenuItem.Text = "Add [VMess] Server"; this.AddVMessServerToolStripMenuItem.Click += new System.EventHandler(this.AddVMessServerToolStripMenuItem_Click); // @@ -170,20 +170,20 @@ namespace Netch.Forms this.ManageProcessModeToolStripMenuItem}); this.ModeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); this.ModeToolStripMenuItem.Name = "ModeToolStripMenuItem"; - this.ModeToolStripMenuItem.Size = new System.Drawing.Size(50, 19); + this.ModeToolStripMenuItem.Size = new System.Drawing.Size(55, 21); this.ModeToolStripMenuItem.Text = "Mode"; // // CreateProcessModeToolStripMenuItem // this.CreateProcessModeToolStripMenuItem.Name = "CreateProcessModeToolStripMenuItem"; - this.CreateProcessModeToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.CreateProcessModeToolStripMenuItem.Size = new System.Drawing.Size(212, 22); this.CreateProcessModeToolStripMenuItem.Text = "Create Process Mode"; this.CreateProcessModeToolStripMenuItem.Click += new System.EventHandler(this.CreateProcessModeToolStripButton_Click); // // ManageProcessModeToolStripMenuItem // this.ManageProcessModeToolStripMenuItem.Name = "ManageProcessModeToolStripMenuItem"; - this.ManageProcessModeToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.ManageProcessModeToolStripMenuItem.Size = new System.Drawing.Size(212, 22); this.ManageProcessModeToolStripMenuItem.Text = "Manage Process Mode"; this.ManageProcessModeToolStripMenuItem.Click += new System.EventHandler(this.ManageProcessModeToolStripMenuItem_Click); // @@ -194,20 +194,20 @@ namespace Netch.Forms this.UpdateServersFromSubscribeLinksToolStripMenuItem}); this.SubscribeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); this.SubscribeToolStripMenuItem.Name = "SubscribeToolStripMenuItem"; - this.SubscribeToolStripMenuItem.Size = new System.Drawing.Size(70, 19); + this.SubscribeToolStripMenuItem.Size = new System.Drawing.Size(77, 21); this.SubscribeToolStripMenuItem.Text = "Subscribe"; // // ManageSubscribeLinksToolStripMenuItem // this.ManageSubscribeLinksToolStripMenuItem.Name = "ManageSubscribeLinksToolStripMenuItem"; - this.ManageSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.ManageSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22); this.ManageSubscribeLinksToolStripMenuItem.Text = "Manage Subscribe Links"; this.ManageSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.ManageSubscribeLinksToolStripMenuItem_Click); // // UpdateServersFromSubscribeLinksToolStripMenuItem // this.UpdateServersFromSubscribeLinksToolStripMenuItem.Name = "UpdateServersFromSubscribeLinksToolStripMenuItem"; - this.UpdateServersFromSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.UpdateServersFromSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22); this.UpdateServersFromSubscribeLinksToolStripMenuItem.Text = "Update Servers From Subscribe Links"; this.UpdateServersFromSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.UpdateServersFromSubscribeLinksToolStripMenuItem_Click); // @@ -220,34 +220,34 @@ namespace Netch.Forms this.CleanDNSCacheToolStripMenuItem}); this.OptionsToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); this.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem"; - this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(61, 19); + this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21); this.OptionsToolStripMenuItem.Text = "Options"; // // ReloadModesToolStripMenuItem // this.ReloadModesToolStripMenuItem.Name = "ReloadModesToolStripMenuItem"; - this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(177, 22); this.ReloadModesToolStripMenuItem.Text = "Reload Modes"; this.ReloadModesToolStripMenuItem.Click += new System.EventHandler(this.ReloadModesToolStripMenuItem_Click); // // RestartServiceToolStripMenuItem // this.RestartServiceToolStripMenuItem.Name = "RestartServiceToolStripMenuItem"; - this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(177, 22); this.RestartServiceToolStripMenuItem.Text = "Restart Service"; this.RestartServiceToolStripMenuItem.Click += new System.EventHandler(this.RestartServiceToolStripMenuItem_Click); // // UninstallServiceToolStripMenuItem // this.UninstallServiceToolStripMenuItem.Name = "UninstallServiceToolStripMenuItem"; - this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(177, 22); this.UninstallServiceToolStripMenuItem.Text = "Uninstall Service"; this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click); // // CleanDNSCacheToolStripMenuItem // this.CleanDNSCacheToolStripMenuItem.Name = "CleanDNSCacheToolStripMenuItem"; - this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(177, 22); this.CleanDNSCacheToolStripMenuItem.Text = "Clean DNS Cache"; this.CleanDNSCacheToolStripMenuItem.Click += new System.EventHandler(this.CleanDNSCacheToolStripMenuItem_Click); // @@ -257,7 +257,7 @@ namespace Netch.Forms this.AboutToolStripButton.AutoToolTip = false; this.AboutToolStripButton.Margin = new System.Windows.Forms.Padding(0, 0, 3, 1); this.AboutToolStripButton.Name = "AboutToolStripButton"; - this.AboutToolStripButton.Size = new System.Drawing.Size(44, 19); + this.AboutToolStripButton.Size = new System.Drawing.Size(47, 21); this.AboutToolStripButton.Text = "About"; this.AboutToolStripButton.Click += new System.EventHandler(this.AboutToolStripButton_Click); // @@ -269,7 +269,7 @@ namespace Netch.Forms this.VersionLabel.IsLink = true; this.VersionLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; this.VersionLabel.Name = "VersionLabel"; - this.VersionLabel.Size = new System.Drawing.Size(31, 17); + this.VersionLabel.Size = new System.Drawing.Size(32, 19); this.VersionLabel.Text = "x.x.x"; this.VersionLabel.Click += new System.EventHandler(this.VersionLabel_Click); // @@ -493,27 +493,27 @@ namespace Netch.Forms // this.StatusLabel.BackColor = System.Drawing.Color.Transparent; this.StatusLabel.Name = "StatusLabel"; - this.StatusLabel.Size = new System.Drawing.Size(162, 17); + this.StatusLabel.Size = new System.Drawing.Size(177, 17); this.StatusLabel.Text = "Status: Waiting for command"; // // UsedBandwidthLabel // this.UsedBandwidthLabel.Name = "UsedBandwidthLabel"; - this.UsedBandwidthLabel.Size = new System.Drawing.Size(62, 17); + this.UsedBandwidthLabel.Size = new System.Drawing.Size(72, 17); this.UsedBandwidthLabel.Text = "Used: 0 KB"; this.UsedBandwidthLabel.Visible = false; // // DownloadSpeedLabel // this.DownloadSpeedLabel.Name = "DownloadSpeedLabel"; - this.DownloadSpeedLabel.Size = new System.Drawing.Size(52, 17); + this.DownloadSpeedLabel.Size = new System.Drawing.Size(59, 17); this.DownloadSpeedLabel.Text = "↓: 0 KB/s"; this.DownloadSpeedLabel.Visible = false; // // UploadSpeedLabel // this.UploadSpeedLabel.Name = "UploadSpeedLabel"; - this.UploadSpeedLabel.Size = new System.Drawing.Size(52, 17); + this.UploadSpeedLabel.Size = new System.Drawing.Size(59, 17); this.UploadSpeedLabel.Text = "↑: 0 KB/s"; this.UploadSpeedLabel.Visible = false; // @@ -549,19 +549,19 @@ namespace Netch.Forms this.ExitToolStripButton}); this.NotifyMenu.Name = "NotifyMenu"; this.NotifyMenu.ShowItemToolTips = false; - this.NotifyMenu.Size = new System.Drawing.Size(104, 48); + this.NotifyMenu.Size = new System.Drawing.Size(108, 48); // // ShowMainFormToolStripButton // this.ShowMainFormToolStripButton.Name = "ShowMainFormToolStripButton"; - this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(103, 22); + this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(107, 22); this.ShowMainFormToolStripButton.Text = "Show"; this.ShowMainFormToolStripButton.Click += new System.EventHandler(this.ShowMainFormToolStripButton_Click); // // ExitToolStripButton // this.ExitToolStripButton.Name = "ExitToolStripButton"; - this.ExitToolStripButton.Size = new System.Drawing.Size(103, 22); + this.ExitToolStripButton.Size = new System.Drawing.Size(107, 22); this.ExitToolStripButton.Text = "Exit"; this.ExitToolStripButton.Click += new System.EventHandler(this.ExitToolStripButton_Click); // @@ -613,7 +613,7 @@ namespace Netch.Forms this.Controls.Add(this.StatusStrip); this.Controls.Add(this.ConfigurationGroupBox); this.Controls.Add(this.MenuStrip); - this.Font = new System.Drawing.Font("Microsoft YaHei", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 0f408b80..82407e85 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -875,25 +875,28 @@ namespace Netch.Forms } State = Models.State.Started; - // 自动检测延迟 - Task.Run(() => + if (Global.Settings.StartedTcping) { - while (true) + // 自动检测延迟 + Task.Run(() => { - if (State == Models.State.Started) + while (true) { - server.Test(); + if (State == Models.State.Started) + { + server.Test(); // 重载服务器列表 InitServer(); - Thread.Sleep(1000); + Thread.Sleep(Global.Settings.StartedTcping_Interval * 1000); + } + else + { + break; + } } - else - { - break; - } - } - }); + }); + } } else { @@ -1101,7 +1104,7 @@ namespace Netch.Forms var num_profile = Global.Settings.ProfileCount; if (num_profile == 0) { - ProfileGroupBox.Size = new Size(0,0); + ProfileGroupBox.Size = new Size(0, 0); ConfigurationGroupBox.Size -= new Size(0, 25); this.Size -= new Size(0, 70 + 25); configLayoutPanel.RowStyles[2].Height = 0; diff --git a/Netch/Forms/MainForm.resx b/Netch/Forms/MainForm.resx index 1f893d4d..3e9e21a2 100644 --- a/Netch/Forms/MainForm.resx +++ b/Netch/Forms/MainForm.resx @@ -121,20 +121,18 @@ 17, 17 - + - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAk9JREFUOE9N - k19ojWEcx8+xsRgzbSlaJouGRCNuXIyMXJ1LpVyYFAttqylEsdKQC1yZpF24oJQrN0q5UJKUlP3DWTPz - pzmm2Tk753nf9+fzfd/3nJ2nPr3v8z7P7/d7nu/v+ybMbBUsA703wwk/sKcPJz07POzszOg8HXAKBr55 - bLMmWKOgxZCEBfH7zg9/fev55Gw8G9jUXGC/IFMI7HXGt7ZBZ9fGHNtsJVQogYIrQMFVOc8GLn5x4eby - UWB6k8AXU75N5gJ9aoBkMYGqL4JLbHB9bFRA+Xj207Pr0fcbTNtgC1QWE1TC6t/5INvF0UdmwgqlkZ4N - rJvvP3JBmul6OArSrloJ6mAz3H383bMHE6FApZFlqitpbcbZhTnfWrzA9rNUDfVKsAFSY1Q5+9mFopWP - IU6TGnJ2nrXetCslY6hwnRLo/q1XWVTr/iHwdCECQS2PFpl81IUnBLZ+LNit8bALRyA8gTTY0f816vVl - Klwh2UneH5GweJ53076d5pv04SrSQiLWKkEVbFUl9VtItPYRZ6/iVr7549sx5sORuP2wBw5BgxIsgY2w - DVZAlwLVc21/GwdTWRfvhXp4Cbv1rgRrQRbeDge466xaplO8x5FxMEvWCctBRTpgH4RGWgdyoRZuSyiJ - qcrSIQ5+DgtBCXQCuXAphFaWjfVsnMD752iX2tQ5b6g7sAv0w20CiV50b3gCuTDB1ub7mGjvYCF0XRzc - B/rrGkGqK7BYVI5MaFILSdzVdI9WHuRvG42Cj4Mc2g4toEJKUAMZSJlZzX8eY2N9ZDKIEQAAAABJRU5E - rkJggg== + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAg9JREFUOE+F + U81uElEYnTdw58qFunBlYnwAE7e+QhMT38CNcefWxKWufADjiqqtmsZIW2gRulBTY4fGGGmLMFOGn5aB + GYa5c+f4nTsINKF6kkPIxz3nO/f7Llas1IXXGyW8Wi9h+T/kmVx+C7WGA8F14S2LxR8HdfjDAMMwFI7O + YQg/CI14pVDGKIoGYnDZomMgB4gk0VAqgUoWkxjHMd5t7eCkTz2uWIxGd601nHYPR66H+nH7LKXW9LrG + JBrHeL+9g1N/gDRNl4wBoxHhKDJxmWierPG3lGeiaGrQ9DpPjMFADJjA7fSko4ff0nWerDntWQJegQbl + XRsLEiweZMAEEoFn1opl9GXopa97sFaLlWmCY0nAjo2WdCYn3ednIGvHodPCSIw+2z9hrRQqZoWzBLOu + jBvJ1MlYyARK+LGl8LCWYq+vsyvMttA17oduiwOaru4vEhGvdzSuVRUu2THu7KvJDCYJxrHKugr5XdZk + 6kSsgWJXo+pr7J5q3K7GeFoXA75EDuRfYOyCdLZFTDhhipyboDsIv2QGg6H5YREorvSyzgTFH7wEnh8g + 0frxdAbn4Vs/xYtmNguK10TcCXjF+JmUrlpvNj/lDxqu2cDZFxialb1sKly0FZYl8oZc4yRK+CYeiPie + 8IYlH3dz+W3zuub5Vv5x33/V8VwG9aimsCniMEl92dZN0SxRB+D+Hw2grtB8iuYFAAAAAElFTkSuQmCC @@ -151,18 +149,20 @@ R+QMmWB7l2jP55IkExaBIP+X+VaqtcbLMAynmftgqMOzv61mlBRRiHFjAAAAAElFTkSuQmCC - + - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAg9JREFUOE+F - U81uElEYnTdw58qFunBlYnwAE7e+QhMT38CNcefWxKWufADjiqqtmsZIW2gRulBTY4fGGGmLMFOGn5aB - GYa5c+f4nTsINKF6kkPIxz3nO/f7Llas1IXXGyW8Wi9h+T/kmVx+C7WGA8F14S2LxR8HdfjDAMMwFI7O - YQg/CI14pVDGKIoGYnDZomMgB4gk0VAqgUoWkxjHMd5t7eCkTz2uWIxGd601nHYPR66H+nH7LKXW9LrG - JBrHeL+9g1N/gDRNl4wBoxHhKDJxmWierPG3lGeiaGrQ9DpPjMFADJjA7fSko4ff0nWerDntWQJegQbl - XRsLEiweZMAEEoFn1opl9GXopa97sFaLlWmCY0nAjo2WdCYn3ednIGvHodPCSIw+2z9hrRQqZoWzBLOu - jBvJ1MlYyARK+LGl8LCWYq+vsyvMttA17oduiwOaru4vEhGvdzSuVRUu2THu7KvJDCYJxrHKugr5XdZk - 6kSsgWJXo+pr7J5q3K7GeFoXA75EDuRfYOyCdLZFTDhhipyboDsIv2QGg6H5YREorvSyzgTFH7wEnh8g - 0frxdAbn4Vs/xYtmNguK10TcCXjF+JmUrlpvNj/lDxqu2cDZFxialb1sKly0FZYl8oZc4yRK+CYeiPie - 8IYlH3dz+W3zuub5Vv5x33/V8VwG9aimsCniMEl92dZN0SxRB+D+Hw2grtB8iuYFAAAAAElFTkSuQmCC + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAk9JREFUOE9N + k19ojWEcx8+xsRgzbSlaJouGRCNuXIyMXJ1LpVyYFAttqylEsdKQC1yZpF24oJQrN0q5UJKUlP3DWTPz + pzmm2Tk753nf9+fzfd/3nJ2nPr3v8z7P7/d7nu/v+ybMbBUsA703wwk/sKcPJz07POzszOg8HXAKBr55 + bLMmWKOgxZCEBfH7zg9/fev55Gw8G9jUXGC/IFMI7HXGt7ZBZ9fGHNtsJVQogYIrQMFVOc8GLn5x4eby + UWB6k8AXU75N5gJ9aoBkMYGqL4JLbHB9bFRA+Xj207Pr0fcbTNtgC1QWE1TC6t/5INvF0UdmwgqlkZ4N + rJvvP3JBmul6OArSrloJ6mAz3H383bMHE6FApZFlqitpbcbZhTnfWrzA9rNUDfVKsAFSY1Q5+9mFopWP + IU6TGnJ2nrXetCslY6hwnRLo/q1XWVTr/iHwdCECQS2PFpl81IUnBLZ+LNit8bALRyA8gTTY0f816vVl + Klwh2UneH5GweJ53076d5pv04SrSQiLWKkEVbFUl9VtItPYRZ6/iVr7549sx5sORuP2wBw5BgxIsgY2w + DVZAlwLVc21/GwdTWRfvhXp4Cbv1rgRrQRbeDge466xaplO8x5FxMEvWCctBRTpgH4RGWgdyoRZuSyiJ + qcrSIQ5+DgtBCXQCuXAphFaWjfVsnMD752iX2tQ5b6g7sAv0w20CiV50b3gCuTDB1ub7mGjvYCF0XRzc + B/rrGkGqK7BYVI5MaFILSdzVdI9WHuRvG42Cj4Mc2g4toEJKUAMZSJlZzX8eY2N9ZDKIEQAAAABJRU5E + rkJggg== diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs index 4060d8d0..b3ff6797 100644 --- a/Netch/Forms/SettingForm.Designer.cs +++ b/Netch/Forms/SettingForm.Designer.cs @@ -49,8 +49,13 @@ this.ControlButton = new System.Windows.Forms.Button(); this.GlobalBypassIPsButton = new System.Windows.Forms.Button(); this.BehaviorGroupBox = new System.Windows.Forms.GroupBox(); + this.DetectionInterval_Label = new System.Windows.Forms.Label(); + this.DetectionInterval_TextBox = new System.Windows.Forms.TextBox(); + this.EnableStartedTcping_CheckBox = new System.Windows.Forms.CheckBox(); + this.DelayTestAfterStartup_Label = new System.Windows.Forms.Label(); + this.BypassModeCheckBox = new System.Windows.Forms.CheckBox(); this.Redirector2checkBox = new System.Windows.Forms.CheckBox(); - this.label3 = new System.Windows.Forms.Label(); + this.ExperimentalFunction_Label = new System.Windows.Forms.Label(); this.STUN_ServerPortTextBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); @@ -63,7 +68,6 @@ this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox(); this.ExitWhenClosedCheckBox = new System.Windows.Forms.CheckBox(); - this.BypassModeCheckBox = new System.Windows.Forms.CheckBox(); this.PortGroupBox.SuspendLayout(); this.TUNTAPGroupBox.SuspendLayout(); this.BehaviorGroupBox.SuspendLayout(); @@ -239,7 +243,7 @@ // ControlButton // this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ControlButton.Location = new System.Drawing.Point(357, 679); + this.ControlButton.Location = new System.Drawing.Point(781, 356); this.ControlButton.Name = "ControlButton"; this.ControlButton.Size = new System.Drawing.Size(75, 23); this.ControlButton.TabIndex = 11; @@ -250,7 +254,7 @@ // GlobalBypassIPsButton // this.GlobalBypassIPsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.GlobalBypassIPsButton.Location = new System.Drawing.Point(12, 679); + this.GlobalBypassIPsButton.Location = new System.Drawing.Point(12, 356); this.GlobalBypassIPsButton.Name = "GlobalBypassIPsButton"; this.GlobalBypassIPsButton.Size = new System.Drawing.Size(128, 23); this.GlobalBypassIPsButton.TabIndex = 10; @@ -260,9 +264,13 @@ // // BehaviorGroupBox // + this.BehaviorGroupBox.Controls.Add(this.DetectionInterval_Label); + this.BehaviorGroupBox.Controls.Add(this.DetectionInterval_TextBox); + this.BehaviorGroupBox.Controls.Add(this.EnableStartedTcping_CheckBox); + this.BehaviorGroupBox.Controls.Add(this.DelayTestAfterStartup_Label); this.BehaviorGroupBox.Controls.Add(this.BypassModeCheckBox); this.BehaviorGroupBox.Controls.Add(this.Redirector2checkBox); - this.BehaviorGroupBox.Controls.Add(this.label3); + this.BehaviorGroupBox.Controls.Add(this.ExperimentalFunction_Label); this.BehaviorGroupBox.Controls.Add(this.STUN_ServerPortTextBox); this.BehaviorGroupBox.Controls.Add(this.label2); this.BehaviorGroupBox.Controls.Add(this.label1); @@ -275,35 +283,82 @@ this.BehaviorGroupBox.Controls.Add(this.StartWhenOpenedCheckBox); this.BehaviorGroupBox.Controls.Add(this.StopWhenExitedCheckBox); this.BehaviorGroupBox.Controls.Add(this.ExitWhenClosedCheckBox); - this.BehaviorGroupBox.Location = new System.Drawing.Point(12, 351); + this.BehaviorGroupBox.Location = new System.Drawing.Point(438, 12); this.BehaviorGroupBox.Name = "BehaviorGroupBox"; - this.BehaviorGroupBox.Size = new System.Drawing.Size(420, 312); + this.BehaviorGroupBox.Size = new System.Drawing.Size(420, 333); this.BehaviorGroupBox.TabIndex = 8; this.BehaviorGroupBox.TabStop = false; this.BehaviorGroupBox.Text = "Behavior"; // + // DetectionInterval_Label + // + this.DetectionInterval_Label.AutoSize = true; + this.DetectionInterval_Label.Location = new System.Drawing.Point(230, 151); + this.DetectionInterval_Label.Name = "DetectionInterval_Label"; + this.DetectionInterval_Label.Size = new System.Drawing.Size(128, 17); + this.DetectionInterval_Label.TabIndex = 18; + this.DetectionInterval_Label.Text = "Detection interval(/s)"; + // + // DetectionInterval_TextBox + // + this.DetectionInterval_TextBox.Location = new System.Drawing.Point(364, 148); + this.DetectionInterval_TextBox.Name = "DetectionInterval_TextBox"; + this.DetectionInterval_TextBox.Size = new System.Drawing.Size(47, 23); + this.DetectionInterval_TextBox.TabIndex = 17; + this.DetectionInterval_TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // EnableStartedTcping_CheckBox + // + this.EnableStartedTcping_CheckBox.AutoSize = true; + this.EnableStartedTcping_CheckBox.Location = new System.Drawing.Point(152, 150); + this.EnableStartedTcping_CheckBox.Name = "EnableStartedTcping_CheckBox"; + this.EnableStartedTcping_CheckBox.Size = new System.Drawing.Size(66, 21); + this.EnableStartedTcping_CheckBox.TabIndex = 15; + this.EnableStartedTcping_CheckBox.Text = "Enable"; + this.EnableStartedTcping_CheckBox.UseVisualStyleBackColor = true; + // + // DelayTestAfterStartup_Label + // + this.DelayTestAfterStartup_Label.AutoSize = true; + this.DelayTestAfterStartup_Label.Location = new System.Drawing.Point(6, 151); + this.DelayTestAfterStartup_Label.Name = "DelayTestAfterStartup_Label"; + this.DelayTestAfterStartup_Label.Size = new System.Drawing.Size(141, 17); + this.DelayTestAfterStartup_Label.TabIndex = 16; + this.DelayTestAfterStartup_Label.Text = "Delay test after startup"; + // + // BypassModeCheckBox + // + this.BypassModeCheckBox.AutoSize = true; + this.BypassModeCheckBox.Location = new System.Drawing.Point(276, 232); + this.BypassModeCheckBox.Name = "BypassModeCheckBox"; + this.BypassModeCheckBox.Size = new System.Drawing.Size(135, 21); + this.BypassModeCheckBox.TabIndex = 14; + this.BypassModeCheckBox.Text = "进程代理白名单模式"; + this.BypassModeCheckBox.UseVisualStyleBackColor = true; + this.BypassModeCheckBox.CheckedChanged += new System.EventHandler(this.BypassModeCheckBox_CheckedChanged); + // // Redirector2checkBox // this.Redirector2checkBox.AutoSize = true; - this.Redirector2checkBox.Location = new System.Drawing.Point(120, 266); + this.Redirector2checkBox.Location = new System.Drawing.Point(152, 232); this.Redirector2checkBox.Name = "Redirector2checkBox"; this.Redirector2checkBox.Size = new System.Drawing.Size(118, 21); this.Redirector2checkBox.TabIndex = 11; this.Redirector2checkBox.Text = "是否启用2号核心"; this.Redirector2checkBox.UseVisualStyleBackColor = true; // - // label3 + // ExperimentalFunction_Label // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(9, 267); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(68, 17); - this.label3.TabIndex = 13; - this.label3.Text = "实验性功能"; + this.ExperimentalFunction_Label.AutoSize = true; + this.ExperimentalFunction_Label.Location = new System.Drawing.Point(6, 233); + this.ExperimentalFunction_Label.Name = "ExperimentalFunction_Label"; + this.ExperimentalFunction_Label.Size = new System.Drawing.Size(133, 17); + this.ExperimentalFunction_Label.TabIndex = 13; + this.ExperimentalFunction_Label.Text = "Experimental function"; // // STUN_ServerPortTextBox // - this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(120, 237); + this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(117, 203); this.STUN_ServerPortTextBox.Name = "STUN_ServerPortTextBox"; this.STUN_ServerPortTextBox.Size = new System.Drawing.Size(294, 23); this.STUN_ServerPortTextBox.TabIndex = 8; @@ -312,7 +367,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(9, 243); + this.label2.Location = new System.Drawing.Point(6, 209); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(110, 17); this.label2.TabIndex = 12; @@ -321,7 +376,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(9, 214); + this.label1.Location = new System.Drawing.Point(6, 180); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(82, 17); this.label1.TabIndex = 10; @@ -330,7 +385,7 @@ // RunAtStartup // this.RunAtStartup.AutoSize = true; - this.RunAtStartup.Location = new System.Drawing.Point(120, 130); + this.RunAtStartup.Location = new System.Drawing.Point(12, 75); this.RunAtStartup.Name = "RunAtStartup"; this.RunAtStartup.Size = new System.Drawing.Size(109, 21); this.RunAtStartup.TabIndex = 11; @@ -339,7 +394,7 @@ // // STUN_ServerTextBox // - this.STUN_ServerTextBox.Location = new System.Drawing.Point(120, 211); + this.STUN_ServerTextBox.Location = new System.Drawing.Point(117, 177); this.STUN_ServerTextBox.Name = "STUN_ServerTextBox"; this.STUN_ServerTextBox.Size = new System.Drawing.Size(294, 23); this.STUN_ServerTextBox.TabIndex = 11; @@ -348,7 +403,7 @@ // MinimizeWhenStartedCheckBox // this.MinimizeWhenStartedCheckBox.AutoSize = true; - this.MinimizeWhenStartedCheckBox.Location = new System.Drawing.Point(120, 103); + this.MinimizeWhenStartedCheckBox.Location = new System.Drawing.Point(206, 48); this.MinimizeWhenStartedCheckBox.Name = "MinimizeWhenStartedCheckBox"; this.MinimizeWhenStartedCheckBox.Size = new System.Drawing.Size(158, 21); this.MinimizeWhenStartedCheckBox.TabIndex = 10; @@ -358,7 +413,7 @@ // ProfileCount_Label // this.ProfileCount_Label.AutoSize = true; - this.ProfileCount_Label.Location = new System.Drawing.Point(9, 185); + this.ProfileCount_Label.Location = new System.Drawing.Point(6, 123); this.ProfileCount_Label.Name = "ProfileCount_Label"; this.ProfileCount_Label.Size = new System.Drawing.Size(79, 17); this.ProfileCount_Label.TabIndex = 8; @@ -366,16 +421,16 @@ // // ProfileCount_TextBox // - this.ProfileCount_TextBox.Location = new System.Drawing.Point(222, 182); + this.ProfileCount_TextBox.Location = new System.Drawing.Point(203, 120); this.ProfileCount_TextBox.Name = "ProfileCount_TextBox"; - this.ProfileCount_TextBox.Size = new System.Drawing.Size(192, 23); + this.ProfileCount_TextBox.Size = new System.Drawing.Size(208, 23); this.ProfileCount_TextBox.TabIndex = 9; this.ProfileCount_TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // CheckUpdateWhenOpenedCheckBox // this.CheckUpdateWhenOpenedCheckBox.AutoSize = true; - this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 157); + this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(206, 75); this.CheckUpdateWhenOpenedCheckBox.Name = "CheckUpdateWhenOpenedCheckBox"; this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(190, 21); this.CheckUpdateWhenOpenedCheckBox.TabIndex = 8; @@ -386,7 +441,7 @@ // StartWhenOpenedCheckBox // this.StartWhenOpenedCheckBox.AutoSize = true; - this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 76); + this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(12, 48); this.StartWhenOpenedCheckBox.Name = "StartWhenOpenedCheckBox"; this.StartWhenOpenedCheckBox.Size = new System.Drawing.Size(137, 21); this.StartWhenOpenedCheckBox.TabIndex = 7; @@ -397,7 +452,7 @@ // StopWhenExitedCheckBox // this.StopWhenExitedCheckBox.AutoSize = true; - this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(120, 49); + this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(206, 22); this.StopWhenExitedCheckBox.Name = "StopWhenExitedCheckBox"; this.StopWhenExitedCheckBox.Size = new System.Drawing.Size(127, 21); this.StopWhenExitedCheckBox.TabIndex = 6; @@ -408,7 +463,7 @@ // ExitWhenClosedCheckBox // this.ExitWhenClosedCheckBox.AutoSize = true; - this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(120, 22); + this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(12, 21); this.ExitWhenClosedCheckBox.Name = "ExitWhenClosedCheckBox"; this.ExitWhenClosedCheckBox.Size = new System.Drawing.Size(123, 21); this.ExitWhenClosedCheckBox.TabIndex = 5; @@ -416,22 +471,11 @@ this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.ExitWhenClosedCheckBox.UseVisualStyleBackColor = true; // - // BypassModeCheckBox - // - this.BypassModeCheckBox.AutoSize = true; - this.BypassModeCheckBox.Location = new System.Drawing.Point(237, 266); - this.BypassModeCheckBox.Name = "BypassModeCheckBox"; - this.BypassModeCheckBox.Size = new System.Drawing.Size(135, 21); - this.BypassModeCheckBox.TabIndex = 14; - this.BypassModeCheckBox.Text = "进程代理白名单模式"; - this.BypassModeCheckBox.UseVisualStyleBackColor = true; - this.BypassModeCheckBox.CheckedChanged += new System.EventHandler(this.BypassModeCheckBox_CheckedChanged); - // // SettingForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(444, 713); + this.ClientSize = new System.Drawing.Size(868, 390); this.Controls.Add(this.BehaviorGroupBox); this.Controls.Add(this.PortGroupBox); this.Controls.Add(this.GlobalBypassIPsButton); @@ -492,7 +536,11 @@ private System.Windows.Forms.TextBox STUN_ServerPortTextBox; private System.Windows.Forms.CheckBox TUNTAPProxyDNSCheckBox; private System.Windows.Forms.CheckBox Redirector2checkBox; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label ExperimentalFunction_Label; private System.Windows.Forms.CheckBox BypassModeCheckBox; + private System.Windows.Forms.TextBox DetectionInterval_TextBox; + private System.Windows.Forms.CheckBox EnableStartedTcping_CheckBox; + private System.Windows.Forms.Label DelayTestAfterStartup_Label; + private System.Windows.Forms.Label DetectionInterval_Label; } } \ No newline at end of file diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs index 606d9eac..c988b379 100644 --- a/Netch/Forms/SettingForm.cs +++ b/Netch/Forms/SettingForm.cs @@ -64,6 +64,8 @@ namespace Netch.Forms RunAtStartup.Checked = Global.Settings.RunAtStartup; Redirector2checkBox.Checked = Global.Settings.UseRedirector2; BypassModeCheckBox.Checked = Global.Settings.ProcessBypassMode; + EnableStartedTcping_CheckBox.Checked = Global.Settings.StartedTcping; + DetectionInterval_TextBox.Text = Global.Settings.StartedTcping_Interval.ToString(); Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString(); HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString(); @@ -83,6 +85,11 @@ namespace Netch.Forms RunAtStartup.Text = Utils.i18N.Translate(RunAtStartup.Text); CheckUpdateWhenOpenedCheckBox.Text = Utils.i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text); ProfileCount_Label.Text = Utils.i18N.Translate(ProfileCount_Label.Text); + ExperimentalFunction_Label.Text = Utils.i18N.Translate(ExperimentalFunction_Label.Text); + DelayTestAfterStartup_Label.Text = Utils.i18N.Translate(DelayTestAfterStartup_Label.Text); + EnableStartedTcping_CheckBox.Text = Utils.i18N.Translate(EnableStartedTcping_CheckBox.Text); + DetectionInterval_Label.Text = Utils.i18N.Translate(DetectionInterval_Label.Text); + DelayTestAfterStartup_Label.Text = Utils.i18N.Translate(DelayTestAfterStartup_Label.Text); ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString(); STUN_ServerTextBox.Text = Global.Settings.STUN_Server.ToString(); @@ -148,6 +155,7 @@ namespace Netch.Forms Global.Settings.RunAtStartup = RunAtStartup.Checked; Global.Settings.UseRedirector2 = Redirector2checkBox.Checked; Global.Settings.ProcessBypassMode = BypassModeCheckBox.Checked; + Global.Settings.StartedTcping = EnableStartedTcping_CheckBox.Checked; // 开机自启判断 TaskSchedulerClass scheduler = new TaskSchedulerClass(); @@ -314,6 +322,28 @@ namespace Netch.Forms return; } + try + { + Global.Settings.StartedTcping = EnableStartedTcping_CheckBox.Checked; + + var DetectionInterval = int.Parse(DetectionInterval_TextBox.Text); + + if (DetectionInterval > 0) + { + Global.Settings.StartedTcping_Interval = DetectionInterval; + } + else + { + throw new FormatException(); + } + } + catch (FormatException) + { + ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString(); + MessageBox.Show(Utils.i18N.Translate("STUN_ServerPort value illegal. Try again."), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); + + return; + } Global.Settings.TUNTAP.Address = TUNTAPAddressTextBox.Text; Global.Settings.TUNTAP.Netmask = TUNTAPNetmaskTextBox.Text; diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index 1f1e5ff0..84f12f1e 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -158,9 +158,20 @@ namespace Netch.Models /// 是否切换为2号核心 /// public bool UseRedirector2 = false; + /// /// 是否启用进程代理白名单模式 /// public bool ProcessBypassMode = false; + + /// + /// 是否启用启动后延迟测试 + /// + public bool StartedTcping = false; + + /// + /// 启动后延迟测试间隔/秒 + /// + public int StartedTcping_Interval = 3; } } diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index 19085b1c..f19d7bf2 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -153,6 +153,10 @@ "ProfileCount value illegal. Try again.": "快捷配置数值非法。请重试。", "STUN_ServerPort value illegal. Try again.": "STUN端口数值非法。请重试。", "TUN/TAP driver is not detected. Is it installed now?": "未检测到TUN/TAP驱动,是否现在安装?", + "Experimental function": "实验性功能", + "Delay test after startup": "启动后延迟测试", + "Enable": "启用", + "Detection interval(/s)": "检测间隔(/秒)", "Profile": "配置名", "Profiles": "配置",