Revert "A bit of DB model cleanup (#5016)"

This reverts commit 8a3cee9a10.
This commit is contained in:
Pieter-Jan Briers
2021-10-29 16:10:58 +02:00
parent 8a3cee9a10
commit 5c5534de9a
8 changed files with 119 additions and 467 deletions

View File

@@ -18,7 +18,7 @@ namespace Content.Server.IP
}
// First parse the address of the netmask before the prefix length.
var maskAddress = System.Net.IPAddress.Parse(subnetMask[..slashIdx]);
var maskAddress = System.Net.IPAddress.Parse(subnetMask.Substring(0, slashIdx));
if (maskAddress.AddressFamily != address.AddressFamily)
{
@@ -27,18 +27,8 @@ namespace Content.Server.IP
}
// Now find out how long the prefix is.
int maskLength = int.Parse(subnetMask[(slashIdx + 1)..]);
int maskLength = int.Parse(subnetMask.Substring(slashIdx + 1));
return address.IsInSubnet(maskAddress, maskLength);
}
public static bool IsInSubnet(this System.Net.IPAddress address, (System.Net.IPAddress maskAddress, int maskLength) tuple)
{
return address.IsInSubnet(tuple.maskAddress, tuple.maskLength);
}
public static bool IsInSubnet(this System.Net.IPAddress address, System.Net.IPAddress maskAddress, int maskLength)
{
if (maskAddress.AddressFamily == AddressFamily.InterNetwork)
{
// Convert the mask address to an unsigned integer.