Browse Source
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.pull/85/head
2 changed files with 47 additions and 5 deletions
@ -1,5 +1,26 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
set -euo pipefail |
||||
|
|
||||
gateway="$(ip -o -4 route show to default | awk '/via/ {print $3}' | head -1)" |
gateway="$(ip -o -4 route show to default | awk '/via/ {print $3}' | head -1)" |
||||
while read -r remote; do |
if [[ -z "${gateway}" ]]; then |
||||
sudo ip r add $remote via $gateway |
echo "Could not determine default gateway" >&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
ip_cmd=(ip) |
||||
|
if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then |
||||
|
ip_cmd=(sudo ip) |
||||
|
fi |
||||
|
|
||||
|
while IFS= read -r remote; do |
||||
|
remote="${remote%$'\r'}" |
||||
|
[[ -z "$remote" ]] && continue |
||||
|
|
||||
|
if [[ ! "$remote" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then |
||||
|
echo "Skipping unexpected input: $remote" >&2 |
||||
|
continue |
||||
|
fi |
||||
|
|
||||
|
echo "Ensuring route to $remote via $gateway" |
||||
|
"${ip_cmd[@]}" route replace "$remote" via "$gateway" |
||||
done |
done |
||||
|
|||||
Loading…
Reference in new issue