📄 dnsdetecaction.cs
字号:
namespace Imps.Client.CommLayer.NetworkDetect
{
using Imps.Client.Resource;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
public class DNSDetecAction : DetectAction
{
public DNSDetecAction()
{
base.Description = "域名";
base.NextStage = NetworkDetectStage.Proxy;
}
public override void BeginDetectAction()
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.StartDetect), this);
}
public override void CancelDetectAction()
{
}
private void StartDetect(object state)
{
Thread.CurrentThread.Name = "Imps.Client.Pc.NetworkDetect.DNSDetecAction";
List<DetectResult> details = new List<DetectResult>();
int num = 0;
for (int i = 0; i < base.DetectData.ServerDnsName.get_Count(); i++)
{
string text = base.DetectData.ServerDnsName.get_Item(i);
try
{
IPAddress[] addressList = Dns.GetHostEntry(text).AddressList;
string text2 = string.Empty;
foreach (IPAddress address in addressList)
{
text2 = text2 + "," + address.ToString();
}
details.Add(new DetectResult(DetectStatus.Passed, text + "<-->" + text2.Substring(1)));
}
catch
{
details.Add(new DetectResult(DetectStatus.Failed, string.Format(StringTable.NetworkDetect.CanNotParse, text)));
num++;
}
}
base.FireDetecFinsihedEvent(this, new DetectEventArgs(num == 0, details));
}
public override NetworkDetectStage CurrentStage
{
get
{
return NetworkDetectStage.DNS;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -