mirror of
https://github.com/netchx/netch.git
synced 2026-05-01 22:19:37 +08:00
点击NAT label和状态灯即可重测NAT
This commit is contained in:
@@ -235,6 +235,22 @@ namespace Netch.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重测NAT
|
||||
/// </summary>
|
||||
public void RetryNatTest()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
Global.MainForm.NatTypeStatusText(i18N.Translate("Starting NatTester"));
|
||||
// Thread.Sleep(1000);
|
||||
var (nttResult, natType, localEnd, publicEnd) = pNTTController.Start();
|
||||
var country = Utils.Utils.GetCityCode(publicEnd);
|
||||
|
||||
if (nttResult) Global.MainForm.NatTypeStatusText(natType, country);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止
|
||||
/// </summary>
|
||||
|
||||
2
Netch/Forms/MainForm.Designer.cs
generated
2
Netch/Forms/MainForm.Designer.cs
generated
@@ -605,6 +605,7 @@ namespace Netch.Forms
|
||||
this.NatTypeStatusLabel.Size = new System.Drawing.Size(36, 17);
|
||||
this.NatTypeStatusLabel.Text = "NAT:";
|
||||
this.NatTypeStatusLabel.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
|
||||
this.NatTypeStatusLabel.Click += new System.EventHandler(this.NatTypeStatusLabel_Click);
|
||||
//
|
||||
// NatTypeStatusLightLabel
|
||||
//
|
||||
@@ -616,6 +617,7 @@ namespace Netch.Forms
|
||||
this.NatTypeStatusLightLabel.Size = new System.Drawing.Size(18, 21);
|
||||
this.NatTypeStatusLightLabel.Text = "⬤";
|
||||
this.NatTypeStatusLightLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
|
||||
this.NatTypeStatusLightLabel.Click += new System.EventHandler(this.NatTypeStatusLabel_Click);
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
|
||||
@@ -441,5 +441,14 @@ namespace Netch.Forms
|
||||
if (!_comboBoxInitialized) return;
|
||||
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
|
||||
}
|
||||
|
||||
private void NatTypeStatusLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
//一个不太优雅的🔒
|
||||
if (_state == State.Started && NatTypeStatusLabel.ToString().Contains("["))
|
||||
{
|
||||
_mainController.RetryNatTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user