Skip to content

Commit

Permalink
sth
Browse files Browse the repository at this point in the history
  • Loading branch information
mili-tan committed Dec 26, 2020
1 parent e09a993 commit d47a4d5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions AuroraGUI/Tools/Ping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ public static List<int> DnsTest(string ipStr)
stopWatch.Start();
try
{
new DnsClient(IPAddress.Parse(ipStr), 500).Resolve(DomainName.Parse("example.com"));
var msg = new DnsClient(IPAddress.Parse(ipStr), 500).Resolve(DomainName.Parse("example.com"));
if (msg == null || msg.ReturnCode != ReturnCode.NoError) continue;
}
catch
{
continue;
}

stopWatch.Stop();
times.Add(Convert.ToInt32(stopWatch.Elapsed.TotalMilliseconds));
var time = Convert.ToInt32(stopWatch.Elapsed.TotalMilliseconds);
times.Add(time);
Thread.Sleep(100);
}
if (times.Count == 0) times.Add(0);
Expand All @@ -88,8 +91,9 @@ public static List<int> DnsTest(string ipStr)

public static List<int> Curl(string urlStr,string name)
{
var webClient = new MyCurl.MWebClient() { TimeOut = 1000 };
var webClient = new MyCurl.MWebClient() { TimeOut = 600 };
var times = new List<int>();
var ok = true;
for (int i = 0; i < 4; i++)
{
var stopWatch = new Stopwatch();
Expand All @@ -100,10 +104,10 @@ public static List<int> Curl(string urlStr,string name)
}
catch
{
continue;
ok = false;
}
stopWatch.Stop();
times.Add(Convert.ToInt32(stopWatch.Elapsed.TotalMilliseconds));
if (ok) times.Add(Convert.ToInt32(stopWatch.Elapsed.TotalMilliseconds));
Thread.Sleep(50);
}
if (times.Count == 0) times.Add(0);
Expand Down

0 comments on commit d47a4d5

Please sign in to comment.