jellyfin-server/MediaBrowser.Model/Net/IpAddressInfo.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2016-10-26 01:57:58 +00:00
using System;
namespace MediaBrowser.Model.Net
{
public class IpAddressInfo
{
2016-11-08 18:44:23 +00:00
public static IpAddressInfo Any = new IpAddressInfo("0.0.0.0", IpAddressFamily.InterNetwork);
public static IpAddressInfo IPv6Any = new IpAddressInfo("00000000000000000000", IpAddressFamily.InterNetworkV6);
public static IpAddressInfo Loopback = new IpAddressInfo("127.0.0.1", IpAddressFamily.InterNetwork);
2016-11-08 19:50:39 +00:00
public static IpAddressInfo IPv6Loopback = new IpAddressInfo("::1", IpAddressFamily.InterNetworkV6);
2016-11-08 18:44:23 +00:00
2016-10-26 01:57:58 +00:00
public string Address { get; set; }
2016-11-08 18:44:23 +00:00
public IpAddressFamily AddressFamily { get; set; }
public IpAddressInfo(string address, IpAddressFamily addressFamily)
{
if (string.IsNullOrWhiteSpace(address))
{
throw new ArgumentNullException("address");
}
2016-11-08 18:44:23 +00:00
Address = address;
AddressFamily = addressFamily;
}
public bool Equals(IpAddressInfo address)
{
return string.Equals(address.Address, Address, StringComparison.OrdinalIgnoreCase);
}
2016-10-26 01:57:58 +00:00
public override String ToString()
{
return Address;
}
}
2016-11-08 18:44:23 +00:00
public enum IpAddressFamily
{
InterNetwork,
InterNetworkV6
}
2016-10-26 01:57:58 +00:00
}