mirror of
https://github.com/snltty/linker.git
synced 2025-10-23 09:09:27 +08:00
sync
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user