mirror of
https://github.com/snltty/linker.git
synced 2025-11-01 21:13:04 +08:00
sync
This commit is contained in:
@@ -138,7 +138,7 @@ namespace linker.tun
|
||||
error = string.Empty;
|
||||
try
|
||||
{
|
||||
IPAddress network = NetworkHelper.ToNetworkIp(address, NetworkHelper.GetPrefixIP(prefixLength));
|
||||
IPAddress network = NetworkHelper.NetworkIP2IP(address, NetworkHelper.PrefixLength2Value(prefixLength));
|
||||
CommandHelper.Linux(string.Empty, new string[] {
|
||||
$"sysctl -w net.ipv4.ip_forward=1",
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace linker.tun
|
||||
$"iptables -D FORWARD -o {Name} -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
||||
});
|
||||
|
||||
IPAddress network = NetworkHelper.ToNetworkIp(address, NetworkHelper.GetPrefixIP(prefixLength));
|
||||
IPAddress network = NetworkHelper.NetworkIP2IP(address, NetworkHelper.PrefixLength2Value(prefixLength));
|
||||
string iptableLineNumbers = CommandHelper.Linux(string.Empty, new string[] { $"iptables -t nat -L --line-numbers | grep {network}/{prefixLength} | cut -d' ' -f1" });
|
||||
if (string.IsNullOrWhiteSpace(iptableLineNumbers) == false)
|
||||
{
|
||||
@@ -223,8 +223,8 @@ namespace linker.tun
|
||||
{
|
||||
string[] commands = ips.Select(item =>
|
||||
{
|
||||
uint prefixValue = NetworkHelper.GetPrefixIP(item.PrefixLength);
|
||||
IPAddress network = NetworkHelper.ToNetworkIp(item.Address, prefixValue);
|
||||
uint prefixValue = NetworkHelper.PrefixLength2Value(item.PrefixLength);
|
||||
IPAddress network = NetworkHelper.NetworkIP2IP(item.Address, prefixValue);
|
||||
|
||||
return $"ip route add {network}/{item.PrefixLength} via {ip} dev {Name} metric 1 ";
|
||||
}).ToArray();
|
||||
@@ -237,8 +237,8 @@ namespace linker.tun
|
||||
{
|
||||
string[] commands = ip.Select(item =>
|
||||
{
|
||||
uint prefixValue = NetworkHelper.GetPrefixIP(item.PrefixLength);
|
||||
IPAddress network = NetworkHelper.ToNetworkIp(item.Address, prefixValue);
|
||||
uint prefixValue = NetworkHelper.PrefixLength2Value(item.PrefixLength);
|
||||
IPAddress network = NetworkHelper.NetworkIP2IP(item.Address, prefixValue);
|
||||
return $"ip route del {network}/{item.PrefixLength}";
|
||||
}).ToArray();
|
||||
CommandHelper.Linux(string.Empty, commands);
|
||||
|
||||
Reference in New Issue
Block a user