mirror of
https://github.com/netchx/netch.git
synced 2026-04-05 19:45:05 +08:00
添加测速方式(TCPing&ICMPing)切换设置选项
This commit is contained in:
51
Netch/Forms/SettingForm.Designer.cs
generated
51
Netch/Forms/SettingForm.Designer.cs
generated
@@ -34,6 +34,9 @@ namespace Netch.Forms
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingForm));
|
||||
this.TabControl = new System.Windows.Forms.TabControl();
|
||||
this.GeneralTabPage = new System.Windows.Forms.TabPage();
|
||||
this.ServerPingTypeLabel = new System.Windows.Forms.Label();
|
||||
this.TCPingRadioBtn = new System.Windows.Forms.RadioButton();
|
||||
this.ICMPingRadioBtn = new System.Windows.Forms.RadioButton();
|
||||
this.PortGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.Socks5PortLabel = new System.Windows.Forms.Label();
|
||||
this.Socks5PortTextBox = new System.Windows.Forms.TextBox();
|
||||
@@ -143,6 +146,9 @@ namespace Netch.Forms
|
||||
// GeneralTabPage
|
||||
//
|
||||
this.GeneralTabPage.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.GeneralTabPage.Controls.Add(this.ServerPingTypeLabel);
|
||||
this.GeneralTabPage.Controls.Add(this.TCPingRadioBtn);
|
||||
this.GeneralTabPage.Controls.Add(this.ICMPingRadioBtn);
|
||||
this.GeneralTabPage.Controls.Add(this.PortGroupBox);
|
||||
this.GeneralTabPage.Controls.Add(this.BootShadowsocksFromDLLCheckBox);
|
||||
this.GeneralTabPage.Controls.Add(this.ResolveServerHostnameCheckBox);
|
||||
@@ -164,6 +170,39 @@ namespace Netch.Forms
|
||||
this.GeneralTabPage.TabIndex = 0;
|
||||
this.GeneralTabPage.Text = "General";
|
||||
//
|
||||
// ServerPingTypeLabel
|
||||
//
|
||||
this.ServerPingTypeLabel.AutoSize = true;
|
||||
this.ServerPingTypeLabel.Location = new System.Drawing.Point(217, 160);
|
||||
this.ServerPingTypeLabel.Name = "ServerPingTypeLabel";
|
||||
this.ServerPingTypeLabel.Size = new System.Drawing.Size(89, 12);
|
||||
this.ServerPingTypeLabel.TabIndex = 16;
|
||||
this.ServerPingTypeLabel.Text = "ServerPingType";
|
||||
//
|
||||
// TCPingRadioBtn
|
||||
//
|
||||
this.TCPingRadioBtn.AutoSize = true;
|
||||
this.TCPingRadioBtn.Location = new System.Drawing.Point(376, 158);
|
||||
this.TCPingRadioBtn.Name = "TCPingRadioBtn";
|
||||
this.TCPingRadioBtn.Size = new System.Drawing.Size(59, 16);
|
||||
this.TCPingRadioBtn.TabIndex = 15;
|
||||
this.TCPingRadioBtn.TabStop = true;
|
||||
this.TCPingRadioBtn.Text = "TCPing";
|
||||
this.TCPingRadioBtn.UseVisualStyleBackColor = true;
|
||||
this.TCPingRadioBtn.CheckedChanged += new System.EventHandler(this.TCPingRadioBtn_CheckedChanged);
|
||||
//
|
||||
// ICMPingRadioBtn
|
||||
//
|
||||
this.ICMPingRadioBtn.AutoSize = true;
|
||||
this.ICMPingRadioBtn.Location = new System.Drawing.Point(312, 158);
|
||||
this.ICMPingRadioBtn.Name = "ICMPingRadioBtn";
|
||||
this.ICMPingRadioBtn.Size = new System.Drawing.Size(65, 16);
|
||||
this.ICMPingRadioBtn.TabIndex = 14;
|
||||
this.ICMPingRadioBtn.TabStop = true;
|
||||
this.ICMPingRadioBtn.Text = "ICMPing";
|
||||
this.ICMPingRadioBtn.UseVisualStyleBackColor = true;
|
||||
this.ICMPingRadioBtn.CheckedChanged += new System.EventHandler(this.ICMPingRadioBtn_CheckedChanged);
|
||||
//
|
||||
// PortGroupBox
|
||||
//
|
||||
this.PortGroupBox.Controls.Add(this.Socks5PortLabel);
|
||||
@@ -292,7 +331,7 @@ namespace Netch.Forms
|
||||
// DetectionIntervalLabel
|
||||
//
|
||||
this.DetectionIntervalLabel.AutoSize = true;
|
||||
this.DetectionIntervalLabel.Location = new System.Drawing.Point(228, 187);
|
||||
this.DetectionIntervalLabel.Location = new System.Drawing.Point(217, 187);
|
||||
this.DetectionIntervalLabel.Name = "DetectionIntervalLabel";
|
||||
this.DetectionIntervalLabel.Size = new System.Drawing.Size(143, 12);
|
||||
this.DetectionIntervalLabel.TabIndex = 6;
|
||||
@@ -383,6 +422,7 @@ namespace Netch.Forms
|
||||
this.NoProxyForTcpCheckBox.TabIndex = 4;
|
||||
this.NoProxyForTcpCheckBox.Text = "No Proxy for Tcp";
|
||||
this.NoProxyForTcpCheckBox.UseVisualStyleBackColor = true;
|
||||
this.NoProxyForTcpCheckBox.CheckedChanged += new System.EventHandler(this.NoProxyForTcpCheckBox_CheckedChanged);
|
||||
//
|
||||
// NoProxyForUdpCheckBox
|
||||
//
|
||||
@@ -393,6 +433,7 @@ namespace Netch.Forms
|
||||
this.NoProxyForUdpCheckBox.TabIndex = 3;
|
||||
this.NoProxyForUdpCheckBox.Text = "No Proxy for Udp";
|
||||
this.NoProxyForUdpCheckBox.UseVisualStyleBackColor = true;
|
||||
this.NoProxyForUdpCheckBox.CheckedChanged += new System.EventHandler(this.NoProxyForUdpCheckBox_CheckedChanged);
|
||||
//
|
||||
// ModifySystemDNSCheckBox
|
||||
//
|
||||
@@ -929,7 +970,7 @@ namespace Netch.Forms
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControlButton.Location = new System.Drawing.Point(397, 363);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
@@ -960,7 +1001,7 @@ namespace Netch.Forms
|
||||
this.ClientSize = new System.Drawing.Size(480, 400);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "SettingForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
@@ -987,6 +1028,7 @@ namespace Netch.Forms
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
private System.Windows.Forms.CheckBox NoProxyForTcpCheckBox;
|
||||
|
||||
@@ -1071,5 +1113,8 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.Label ModifiedDNSLabel;
|
||||
private System.Windows.Forms.CheckBox RedirectorSSCheckBox;
|
||||
private System.Windows.Forms.CheckBox NoProxyForUdpCheckBox;
|
||||
private System.Windows.Forms.Label ServerPingTypeLabel;
|
||||
private System.Windows.Forms.RadioButton TCPingRadioBtn;
|
||||
private System.Windows.Forms.RadioButton ICMPingRadioBtn;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,14 @@ namespace Netch.Forms
|
||||
c => Global.Settings.ResolveServerHostname = c,
|
||||
Global.Settings.ResolveServerHostname);
|
||||
|
||||
BindRadioBox(ICMPingRadioBtn,
|
||||
c => Global.Settings.ServerTCPing = c,
|
||||
!Global.Settings.ServerTCPing);
|
||||
|
||||
BindRadioBox(TCPingRadioBtn,
|
||||
c => Global.Settings.ServerTCPing = c,
|
||||
Global.Settings.ServerTCPing);
|
||||
|
||||
BindTextBox<int>(ProfileCountTextBox,
|
||||
i => i > -1,
|
||||
i => Global.Settings.ProfileCount = i,
|
||||
@@ -346,17 +354,6 @@ namespace Netch.Forms
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckProcessMode
|
||||
|
||||
if (NoProxyForUdpCheckBox.Checked && NoProxyForTcpCheckBox.Checked)
|
||||
{
|
||||
Utils.Utils.ChangeControlForeColor(STUN_ServerComboBox, Color.Red);
|
||||
MessageBoxX.Show("TCP&UDP只允许勾选一个");
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Save
|
||||
|
||||
foreach (var pair in _saveActions)
|
||||
@@ -432,7 +429,13 @@ namespace Netch.Forms
|
||||
{
|
||||
control.Checked = value;
|
||||
_checkActions.Add(control, s => true);
|
||||
_saveActions.Add(control, c => save.Invoke(((CheckBox) c).Checked));
|
||||
_saveActions.Add(control, c => save.Invoke(((CheckBox)c).Checked));
|
||||
}
|
||||
private void BindRadioBox(RadioButton control, Action<bool> save, bool value)
|
||||
{
|
||||
control.Checked = value;
|
||||
_checkActions.Add(control, s => true);
|
||||
_saveActions.Add(control, c => save.Invoke(((RadioButton)c).Checked));
|
||||
}
|
||||
|
||||
private readonly Dictionary<Control, Func<string, bool>> _checkActions = new Dictionary<Control, Func<string, bool>>();
|
||||
@@ -443,5 +446,25 @@ namespace Netch.Forms
|
||||
{
|
||||
ModifiedDNSTextBox.Enabled = ModifySystemDNSCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void NoProxyForUdpCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (NoProxyForUdpCheckBox.Checked) NoProxyForTcpCheckBox.Checked = false;
|
||||
}
|
||||
|
||||
private void NoProxyForTcpCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (NoProxyForTcpCheckBox.Checked) NoProxyForUdpCheckBox.Checked = false;
|
||||
}
|
||||
|
||||
private void ICMPingRadioBtn_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ICMPingRadioBtn.Checked) TCPingRadioBtn.Checked = false;
|
||||
}
|
||||
|
||||
private void TCPingRadioBtn_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (TCPingRadioBtn.Checked) ICMPingRadioBtn.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Netch.Utils;
|
||||
|
||||
namespace Netch.Models
|
||||
{
|
||||
public class Server:ICloneable
|
||||
public class Server : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// 备注
|
||||
@@ -81,7 +81,7 @@ namespace Netch.Models
|
||||
{
|
||||
try
|
||||
{
|
||||
return await Utils.Utils.TCPingAsync(destination, Port);
|
||||
return Global.Settings.ServerTCPing ? await Utils.Utils.TCPingAsync(destination, Port) : await Utils.Utils.ICMPing(destination, Port);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -272,6 +272,11 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
public string Language = "System";
|
||||
|
||||
/// <summary>
|
||||
/// 服务器测试方式 false.ICMPing true.TCPing
|
||||
/// </summary>
|
||||
public bool ServerTCPing = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用RDR内置SS
|
||||
/// </summary>
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
"Failed to set the system proxy, it may be caused by the lack of dependent programs. Do you want to jump to Netch's official website to download dependent programs?": "设置系统代理失败,可能是缺少依赖导致,是否跳转 Netch 官网下载依赖程序?",
|
||||
"Delay test after start": "启动后延迟测试",
|
||||
"Enable": "启用",
|
||||
"ServerPingType": "测速方式",
|
||||
"Detection interval(sec)": "检测间隔(秒)",
|
||||
"STUN Server": "STUN 服务器",
|
||||
"STUN Server Port": "STUN 服务器端口",
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Netch.Utils
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public static int ICMPing(IPAddress ip, int timeout = 1000)
|
||||
public static async Task<int> ICMPing(IPAddress ip, int timeout = 1000)
|
||||
{
|
||||
var reply = new Ping().Send(ip, timeout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user