commit 8e91a576273baf41434b0bee14309b08333029d7 Author: anor Date: Mon Mar 16 23:58:39 2026 +1000 feat: статические маршруты мимо VPN для десктопа (macOS) - Автоопределение шлюза (Ethernet → Wi-Fi) - Маршруты для 188.214.107.180, 188.241.196.208, 91.234.54.90 - LaunchDaemon с проверкой каждые 5 сек diff --git a/com.custom.staticroutes.plist b/com.custom.staticroutes.plist new file mode 100644 index 0000000..836fd51 --- /dev/null +++ b/com.custom.staticroutes.plist @@ -0,0 +1,20 @@ + + + + + Label + com.custom.staticroutes + ProgramArguments + + /usr/local/bin/set_static_routes.sh + + RunAtLoad + + StartInterval + 5 + StandardOutPath + /tmp/com.custom.staticroutes.out + StandardErrorPath + /tmp/com.custom.staticroutes.err + + diff --git a/set_static_routes.sh b/set_static_routes.sh new file mode 100644 index 0000000..8a72e2e --- /dev/null +++ b/set_static_routes.sh @@ -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