mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-28 03:34:46 +03:00
move classes to new server project
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Net;
|
||||
|
||||
namespace Emby.Common.Implementations.Networking
|
||||
{
|
||||
@@ -382,5 +383,35 @@ namespace Emby.Common.Implementations.Networking
|
||||
|
||||
return hosts[0];
|
||||
}
|
||||
|
||||
public IpAddressInfo ParseIpAddress(string ipAddress)
|
||||
{
|
||||
IpAddressInfo info;
|
||||
if (TryParseIpAddress(ipAddress, out info))
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
throw new ArgumentException("Invalid ip address: " + ipAddress);
|
||||
}
|
||||
|
||||
public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
|
||||
{
|
||||
IPAddress address;
|
||||
if (IPAddress.TryParse(ipAddress, out address))
|
||||
{
|
||||
|
||||
ipAddressInfo = new IpAddressInfo
|
||||
{
|
||||
Address = address.ToString(),
|
||||
IsIpv6 = address.AddressFamily == AddressFamily.InterNetworkV6
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ipAddressInfo = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user