This commit is contained in:
snltty
2024-08-01 22:33:53 +08:00
parent 4663856b4c
commit c813f2f577
29 changed files with 265 additions and 1100 deletions

View File

@@ -8,6 +8,7 @@ using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace linker.libs
{
@@ -184,6 +185,18 @@ namespace linker.libs
{
return new IPAddress(BinaryPrimitives.ReverseEndianness(ip & maskvalue).ToBytes());
}
public static IPAddress ToGatewayIP(IPAddress ip, byte maskLength)
{
uint network = BinaryPrimitives.ReadUInt32BigEndian(ToNetworkIp(ip, NetworkHelper.MaskValue(maskLength)).GetAddressBytes());
IPAddress gateway = new IPAddress(BitConverter.GetBytes(BinaryPrimitives.ReverseEndianness(network + 1)));
return gateway;
}
public static IPAddress ToGatewayIP(uint ip, uint maskValue)
{
uint network = BinaryPrimitives.ReadUInt32BigEndian(ToNetworkIp(ip, maskValue).GetAddressBytes());
IPAddress gateway = new IPAddress(BitConverter.GetBytes(BinaryPrimitives.ReverseEndianness(network + 1)));
return gateway;
}
public static bool NotIPv6Support(IPAddress ip)
{