Skip to content

Commit

Permalink
Support create 0.0.0.0 IpEndPoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
liangminhua committed Jun 13, 2018
1 parent 6d6dc02 commit 5eb08d7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Ether.Network/Utils/NetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ internal static class NetUtils
/// <returns>Parsed <see cref="IPAddress"/>.</returns>
public static IPAddress GetIpAddress(string ipOrHost)
{
string host = Dns.GetHostAddressesAsync(ipOrHost).Result.First().ToString();

return IPAddress.TryParse(host, out IPAddress address) ? address : null;
if (IPAddress.TryParse(ipOrHost, out IPAddress address))
{
return address;
}
else
{
return Dns.GetHostAddressesAsync(ipOrHost).Result
.Where(x => x.AddressFamily == AddressFamily.InterNetwork)
.FirstOrDefault();
}
}

/// <summary>
Expand Down

0 comments on commit 5eb08d7

Please sign in to comment.