mirror of
https://github.com/netchx/netch.git
synced 2026-03-30 19:09:48 +08:00
简化NTT控制器返回值
This commit is contained in:
@@ -205,15 +205,15 @@ namespace Netch.Controllers
|
||||
{
|
||||
Global.MainForm.NatTypeStatusText(i18N.Translate("Starting NatTester"));
|
||||
// Thread.Sleep(1000);
|
||||
var (nttResult, natType, localEnd, publicEnd) = NTTController.Start();
|
||||
var (result, localEnd, publicEnd) = NTTController.Start();
|
||||
|
||||
if (nttResult)
|
||||
if (!string.IsNullOrEmpty(publicEnd))
|
||||
{
|
||||
var country = Utils.Utils.GetCityCode(publicEnd);
|
||||
Global.MainForm.NatTypeStatusText(natType, country);
|
||||
Global.MainForm.NatTypeStatusText(result, country);
|
||||
}
|
||||
else
|
||||
Global.MainForm.NatTypeStatusText(natType);
|
||||
Global.MainForm.NatTypeStatusText(result ?? "Error");
|
||||
|
||||
NttTested = true;
|
||||
});
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Netch.Controllers
|
||||
{
|
||||
private string _localEnd;
|
||||
private string _publicEnd;
|
||||
private string _natType;
|
||||
private bool _nttResult;
|
||||
private string _result;
|
||||
private string _bindingTest;
|
||||
|
||||
public NTTController()
|
||||
{
|
||||
@@ -22,10 +22,9 @@ namespace Netch.Controllers
|
||||
/// 启动 NatTypeTester
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (bool, string, string, string) Start()
|
||||
public (string, string, string) Start()
|
||||
{
|
||||
_nttResult = false;
|
||||
_natType = _localEnd = _publicEnd = null;
|
||||
_result = _localEnd = _publicEnd = null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -36,7 +35,9 @@ namespace Netch.Controllers
|
||||
Instance.BeginOutputReadLine();
|
||||
Instance.BeginErrorReadLine();
|
||||
Instance.WaitForExit();
|
||||
return (_nttResult, _natType, _localEnd, _publicEnd);
|
||||
if (_bindingTest == "Fail")
|
||||
_result = "UdpBlocked";
|
||||
return (_result, _localEnd, _publicEnd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace Netch.Controllers
|
||||
// ignored
|
||||
}
|
||||
|
||||
return (false, null, null, null);
|
||||
return (null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +68,12 @@ namespace Netch.Controllers
|
||||
switch (key)
|
||||
{
|
||||
case "Other address is":
|
||||
case "Binding test":
|
||||
case "Nat mapping behavior":
|
||||
case "Nat filtering behavior":
|
||||
break;
|
||||
case "Binding test":
|
||||
_bindingTest = value;
|
||||
break;
|
||||
case "Local address":
|
||||
_localEnd = value;
|
||||
break;
|
||||
@@ -78,11 +81,10 @@ namespace Netch.Controllers
|
||||
_publicEnd = value;
|
||||
break;
|
||||
case "result":
|
||||
_natType = value;
|
||||
_nttResult = true;
|
||||
_result = value;
|
||||
break;
|
||||
default:
|
||||
_natType = str.Last();
|
||||
_result = str.Last();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user