feat: статические маршруты мимо VPN для десктопа (macOS)

- Автоопределение шлюза (Ethernet → Wi-Fi)
- Маршруты для 188.214.107.180, 188.241.196.208, 91.234.54.90
- LaunchDaemon с проверкой каждые 5 сек
This commit is contained in:
anor
2026-03-16 23:58:39 +10:00
commit 8e91a57627
2 changed files with 52 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.custom.staticroutes</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/set_static_routes.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>5</integer>
<key>StandardOutPath</key>
<string>/tmp/com.custom.staticroutes.out</string>
<key>StandardErrorPath</key>
<string>/tmp/com.custom.staticroutes.err</string>
</dict>
</plist>
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Static routes for desktop
# Ensures VPS IPs always go through local gateway, not VPN tunnel
LOG="/tmp/com.custom.staticroutes.out"
# Получаем шлюз физического интерфейса (НЕ default route — может быть VPN utun)
# Перебираем: Ethernet, проводные USB-адаптеры, Wi-Fi
GATEWAY=""
for SVC in "Ethernet" "Wi-Fi"; do
GW=$(/usr/sbin/networksetup -getinfo "$SVC" 2>/dev/null | awk -F': ' '/^Router:/ {print $2}')
if [ -n "$GW" ]; then
GATEWAY="$GW"
break
fi
done
if [ -z "$GATEWAY" ]; then
exit 0
fi
HOSTS="188.214.107.180 188.241.196.208 91.234.54.90"
for HOST in $HOSTS; do
CURRENT=$(/sbin/route -n get "$HOST" 2>/dev/null | awk '/gateway:/ {print $2}')
if [ "$CURRENT" != "$GATEWAY" ]; then
echo "$(date): $HOST: $CURRENT -> $GATEWAY" >> "$LOG"
/sbin/route -n delete -host "$HOST" >> "$LOG" 2>&1
/sbin/route -n add -host "$HOST" "$GATEWAY" >> "$LOG" 2>&1
fi
done