mirror of
https://github.com/WowLegacyCore/HermesProxy
synced 2026-08-14 20:32:05 -04:00
21 lines
477 B
C#
21 lines
477 B
C#
using System.Linq;
|
|
using System.Net;
|
|
|
|
namespace Framework.Networking;
|
|
|
|
public static class NetworkUtils
|
|
{
|
|
public static IPAddress ResolveOrDirectIp(string hostOrIpaddress)
|
|
{
|
|
IPAddress result;
|
|
if (IPAddress.TryParse(hostOrIpaddress, out result))
|
|
{
|
|
if (IPAddress.IsLoopback(result))
|
|
return IPAddress.Loopback;
|
|
|
|
return result;
|
|
}
|
|
|
|
return Dns.GetHostAddresses(hostOrIpaddress).First();
|
|
}
|
|
}
|