Skip to content

Commit

Permalink
Merge pull request #102 from liangminhua/develop
Browse files Browse the repository at this point in the history
Support create 0.0.0.0 IpEndPoint.
  • Loading branch information
Filipe GP authored Jul 12, 2018
2 parents 6d6dc02 + 5eb08d7 commit 36b094f
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 36b094f

Please sign in to comment.