don't break route scripts on duplicate TURN IPs

VK opens a few parallel connections, so the same TURN IP can show up more than once.

Make the Linux and Windows scripts handle reruns instead of failing on duplicate routes.
This commit is contained in:
gazon673games committed 2026-04-02 13:25:14 +03:00
1 parent 7b8a96ea0d
commit ad3a69f400
2 files changed
+47 -5

No files matched your search

+24 -3
View File
@@ -16,12 +16,33 @@ $input | ForEach-Object {
$addr = $_.Trim()
if ($addr -eq "") { return }
Write-Host "Добавляем маршрут к $addr через $gateway"
if ($addr -notmatch '^\d{1,3}(\.\d{1,3}){3}$') {
Write-Warning "Пропускаем неожиданный ввод: $addr"
return
}
$prefix = "$addr/32"
$existingRoutes = @(Get-NetRoute `
-DestinationPrefix $prefix `
-PolicyStore ActiveStore `
-ErrorAction SilentlyContinue)
if ($existingRoutes | Where-Object { $_.NextHop -eq $gateway }) {
Write-Host "Маршрут к $addr через $gateway уже существует"
return
}
if ($existingRoutes.Count -gt 0) {
Write-Host "Обновляем маршрут к $addr через $gateway"
$existingRoutes | Remove-NetRoute -Confirm:$false -ErrorAction Stop
} else {
Write-Host "Добавляем маршрут к $addr через $gateway"
}
New-NetRoute `
-DestinationPrefix "$addr/32" `
-DestinationPrefix $prefix `
-NextHop $gateway `
-PolicyStore ActiveStore `
-ErrorAction Stop
-ErrorAction Stop | Out-Null
}