From 0811dc57300c8785af14b7ff39bbdc05535d9c46 Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Thu, 26 Feb 2026 22:25:45 -0800 Subject: [PATCH] debug --- common/network/pia-vpn/scripts.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/common/network/pia-vpn/scripts.nix b/common/network/pia-vpn/scripts.nix index 6e6c63f..3c2374c 100644 --- a/common/network/pia-vpn/scripts.nix +++ b/common/network/pia-vpn/scripts.nix @@ -22,30 +22,27 @@ in fi } - # Debug: log what comes after line 1 in a PIA API response. + # Debug: check if a PIA API response has trailing data beyond the JSON. verifyPIAResponse() { local raw=$1 label=$2 - local line_count trailing - line_count=$(echo "$raw" | wc -l) - echo "DEBUG $label: response has $line_count line(s)" - if [[ "$line_count" -gt 1 ]]; then - trailing=$(echo "$raw" | tail -n +2) - echo "DEBUG $label: trailing data: $trailing" + local total_lines + total_lines=$(echo "$raw" | wc -l) + if echo "$raw" | jq -e . >/dev/null 2>&1; then + echo "DEBUG $label: response is valid JSON ($total_lines lines, no trailing signature)" else - echo "DEBUG $label: no trailing data (single-line response)" + echo "DEBUG $label: response has non-JSON content ($total_lines lines). Full response:" + echo "$raw" fi } fetchPIAToken() { - local PIA_USER PIA_PASS raw resp + local PIA_USER PIA_PASS resp echo "Reading PIA credentials..." PIA_USER=$(sed '1q;d' /run/agenix/pia-login.conf) PIA_PASS=$(sed '2q;d' /run/agenix/pia-login.conf) echo "Requesting PIA authentication token..." - raw=$(curl -s $(proxy_args) -u "$PIA_USER:$PIA_PASS" \ + resp=$(curl -s $(proxy_args) -u "$PIA_USER:$PIA_PASS" \ "https://www.privateinternetaccess.com/gtoken/generateToken") - verifyPIAResponse "$raw" "generateToken" - resp=$(echo "$raw" | head -n 1) PIA_TOKEN=$(echo "$resp" | jq -r '.token') if [[ -z "$PIA_TOKEN" || "$PIA_TOKEN" == "null" ]]; then echo "ERROR: Failed to fetch PIA token: $resp" >&2