Skip to content

Commit

Permalink
修正tcping逻辑
Browse files Browse the repository at this point in the history
* 当IP地址存在反向解析结果(例 [xxx].members.linode.com),会连接反向域名的IP地址池,可能导致测速IPv4服务器时连接到IPv6地址并且失败。
  • Loading branch information
yfdyh000 committed Feb 20, 2020
1 parent 7cf6ab4 commit a62f375
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions v2rayN/v2rayN/Handler/SpeedtestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,12 @@ private int GetTcpingTime(string url, int port)

try
{
IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPAddress ipAddress;
if (!System.Net.IPAddress.TryParse(url, out ipAddress))
{
IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
ipAddress = ipHostInfo.AddressList[0];
}

var timer = new Stopwatch();
timer.Start();
Expand Down

0 comments on commit a62f375

Please sign in to comment.