From bdec3793d0a9821d3c22dc8eb97107496ed1c3eb Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Sun, 8 Mar 2026 21:02:50 -0700 Subject: [PATCH] Make PIA connection check more tollerant to hiccups --- common/network/pia-vpn/vpn-container.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/common/network/pia-vpn/vpn-container.nix b/common/network/pia-vpn/vpn-container.nix index 9d80428..e45ed77 100644 --- a/common/network/pia-vpn/vpn-container.nix +++ b/common/network/pia-vpn/vpn-container.nix @@ -270,10 +270,17 @@ in return 0 } - if check_vpn; then - rm -f "$COUNTER_FILE" - exit 0 - fi + MAX_RETRIES=4 + for attempt in $(seq 1 $MAX_RETRIES); do + if check_vpn; then + rm -f "$COUNTER_FILE" + exit 0 + fi + if [ "$attempt" -lt "$MAX_RETRIES" ]; then + echo "Attempt $attempt/$MAX_RETRIES failed, retrying in 5 minutes..." >&2 + sleep 300 + fi + done # Failed — read and update counter (reset if from a previous day) today=$(date +%Y-%m-%d) @@ -302,7 +309,7 @@ in description = "Periodic PIA VPN connectivity check"; wantedBy = [ "timers.target" ]; timerConfig = { - OnCalendar = "*:0/5"; + OnCalendar = "*:0/30"; RandomizedDelaySec = "30s"; }; };