Fix Windows TUN routing loop for SIM modems (0.0.0.0 NextHop)

This commit is contained in:
ospab 2026-05-28 16:40:49 +03:00
parent 5fa957830c
commit 36ef6f2d04
2 changed files with 10 additions and 3 deletions

View File

@ -58,8 +58,11 @@ pub async fn run_native_tunnel(
if ($route) {{\n\ if ($route) {{\n\
$gw = $route.NextHop\n\ $gw = $route.NextHop\n\
$ifIndex = $route.InterfaceIndex\n\ $ifIndex = $route.InterfaceIndex\n\
# Route server IP and gateway directly via real interface (bypass TUN)\n\ if ($gw -eq '0.0.0.0' -or $gw -eq '::') {{\n\
New-NetRoute -DestinationPrefix \"$remote_ip/32\" -NextHop $gw -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\ New-NetRoute -DestinationPrefix \"$remote_ip/32\" -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\
}} else {{\n\
New-NetRoute -DestinationPrefix \"$remote_ip/32\" -NextHop $gw -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\
}}\n\
if ($gw -ne '0.0.0.0') {{\n\ if ($gw -ne '0.0.0.0') {{\n\
New-NetRoute -DestinationPrefix \"$gw/32\" -NextHop '0.0.0.0' -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\ New-NetRoute -DestinationPrefix \"$gw/32\" -NextHop '0.0.0.0' -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\
}}\n\ }}\n\

View File

@ -93,7 +93,11 @@ pub async fn run_wintun_tunnel(
if ($route) {{\n\ if ($route) {{\n\
$gw = $route.NextHop\n\ $gw = $route.NextHop\n\
$ifIndex = $route.InterfaceIndex\n\ $ifIndex = $route.InterfaceIndex\n\
New-NetRoute -DestinationPrefix \"$remote_ip/32\" -NextHop $gw -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\ if ($gw -eq '0.0.0.0' -or $gw -eq '::') {{\n\
New-NetRoute -DestinationPrefix \"$remote_ip/32\" -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\
}} else {{\n\
New-NetRoute -DestinationPrefix \"$remote_ip/32\" -NextHop $gw -InterfaceIndex $ifIndex -RouteMetric 1 -ErrorAction SilentlyContinue\n\
}}\n\
}}\n\ }}\n\
New-NetFirewallRule -DisplayName 'OSTP Tunnel In' -Direction Inbound -Program $exe_path -Action Allow -Enabled True -ErrorAction SilentlyContinue\n\ New-NetFirewallRule -DisplayName 'OSTP Tunnel In' -Direction Inbound -Program $exe_path -Action Allow -Enabled True -ErrorAction SilentlyContinue\n\
New-NetFirewallRule -DisplayName 'OSTP Tunnel Out' -Direction Outbound -Program $exe_path -Action Allow -Enabled True -ErrorAction SilentlyContinue\n", New-NetFirewallRule -DisplayName 'OSTP Tunnel Out' -Direction Outbound -Program $exe_path -Action Allow -Enabled True -ErrorAction SilentlyContinue\n",