Apply review suggestions
This commit is contained in:
parent
d8d5c86d49
commit
a381cd3c76
|
@ -93,11 +93,17 @@ namespace MediaBrowser.Common.Net
|
||||||
ArgumentNullException.ThrowIfNull(mask);
|
ArgumentNullException.ThrowIfNull(mask);
|
||||||
|
|
||||||
byte cidrnet = 0;
|
byte cidrnet = 0;
|
||||||
if (!mask.Equals(IPAddress.Any))
|
if (mask.Equals(IPAddress.Any))
|
||||||
{
|
{
|
||||||
|
return cidrnet;
|
||||||
|
}
|
||||||
|
|
||||||
// GetAddressBytes
|
// GetAddressBytes
|
||||||
Span<byte> bytes = stackalloc byte[mask.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
Span<byte> bytes = stackalloc byte[mask.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
||||||
mask.TryWriteBytes(bytes, out _);
|
if (!mask.TryWriteBytes(bytes, out var bytesWritten))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unable to write address bytes, only {Bytes} bytes written.", bytesWritten);
|
||||||
|
}
|
||||||
|
|
||||||
var zeroed = false;
|
var zeroed = false;
|
||||||
for (var i = 0; i < bytes.Length; i++)
|
for (var i = 0; i < bytes.Length; i++)
|
||||||
|
@ -120,7 +126,6 @@ namespace MediaBrowser.Common.Net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return cidrnet;
|
return cidrnet;
|
||||||
}
|
}
|
||||||
|
@ -273,10 +278,9 @@ namespace MediaBrowser.Common.Net
|
||||||
}
|
}
|
||||||
|
|
||||||
var hosts = new List<string>();
|
var hosts = new List<string>();
|
||||||
var splitSpan = host.Split(':');
|
foreach (var splitSpan in host.Split(':'))
|
||||||
while (splitSpan.MoveNext())
|
|
||||||
{
|
{
|
||||||
hosts.Add(splitSpan.Current.ToString());
|
hosts.Add(splitSpan.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hosts.Count <= 2)
|
if (hosts.Count <= 2)
|
||||||
|
@ -316,7 +320,7 @@ namespace MediaBrowser.Common.Net
|
||||||
}
|
}
|
||||||
else if (hosts.Count <= 9) // 8 octets + port
|
else if (hosts.Count <= 9) // 8 octets + port
|
||||||
{
|
{
|
||||||
splitSpan = host.Split('/');
|
var splitSpan = host.Split('/');
|
||||||
if (splitSpan.MoveNext() && IPAddress.TryParse(splitSpan.Current, out var address))
|
if (splitSpan.MoveNext() && IPAddress.TryParse(splitSpan.Current, out var address))
|
||||||
{
|
{
|
||||||
addresses = new[] { address };
|
addresses = new[] { address };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user