Minor improvements to IPObjects

This commit is contained in:
Bond_009
2021-04-10 22:42:09 +02:00
parent a19a97ca42
commit be9cb7af2c
3 changed files with 15 additions and 25 deletions

View File

@@ -10,16 +10,6 @@ namespace MediaBrowser.Common.Net
/// </summary>
public abstract class IPObject : IEquatable<IPObject>
{
/// <summary>
/// IPv6 Loopback address.
/// </summary>
protected static readonly byte[] Ipv6Loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
/// <summary>
/// IPv4 Loopback address.
/// </summary>
protected static readonly byte[] Ipv4Loopback = { 127, 0, 0, 1 };
/// <summary>
/// The network address of this object.
/// </summary>
@@ -64,7 +54,7 @@ namespace MediaBrowser.Common.Net
/// <param name="address">IP Address to convert.</param>
/// <param name="prefixLength">Subnet prefix.</param>
/// <returns>IPAddress.</returns>
public static (IPAddress Address, byte PrefixLength) NetworkAddressOf(IPAddress address, byte prefixLength)
public static (IPAddress address, byte prefixLength) NetworkAddressOf(IPAddress address, byte prefixLength)
{
if (address == null)
{
@@ -78,7 +68,7 @@ namespace MediaBrowser.Common.Net
if (IsLoopback(address))
{
return (Address: address, PrefixLength: prefixLength);
return (address, prefixLength);
}
// An ip address is just a list of bytes, each one representing a segment on the network.
@@ -110,7 +100,7 @@ namespace MediaBrowser.Common.Net
}
// Return the network address for the prefix.
return (Address: new IPAddress(addressBytes), PrefixLength: prefixLength);
return (new IPAddress(addressBytes), prefixLength);
}
/// <summary>