feat(nordvpn-client): gate macos connect on stable wireguard persistence

This commit is contained in:
2026-03-30 11:55:20 -05:00
parent 8d2c162849
commit a796481875
3 changed files with 547 additions and 104 deletions

View File

@@ -3,16 +3,18 @@ set -eu
ACTION="${1:-}"
case "$ACTION" in
probe|up|down)
probe|up|down|status|cleanup)
;;
*)
echo "Usage: nordvpn-wireguard-helper.sh [probe|up|down]" >&2
echo "Usage: nordvpn-wireguard-helper.sh [probe|up|down|status|cleanup]" >&2
exit 2
;;
esac
WG_QUICK="/opt/homebrew/bin/wg-quick"
WG="/opt/homebrew/bin/wg"
WG_CONFIG="/Users/stefano/.nordvpn-client/wireguard/nordvpnctl.conf"
WG_INTERFACE="nordvpnctl"
PATH="/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH
@@ -21,4 +23,25 @@ if [ "$ACTION" = "probe" ]; then
exit 0
fi
if [ "$ACTION" = "status" ]; then
ACTIVE=0
if [ -x "$WG" ] && "$WG" show "$WG_INTERFACE" >/dev/null 2>&1; then
ACTIVE=1
elif /sbin/ifconfig "$WG_INTERFACE" >/dev/null 2>&1; then
ACTIVE=1
fi
echo "active=$ACTIVE"
echo "interfaceName=$WG_INTERFACE"
if [ -f "$WG_CONFIG" ]; then
echo "configPath=$WG_CONFIG"
fi
exit 0
fi
if [ "$ACTION" = "cleanup" ]; then
"$WG_QUICK" down "$WG_CONFIG" >/dev/null 2>&1 || true
exit 0
fi
exec "$WG_QUICK" "$ACTION" "$WG_CONFIG"