debug
All checks were successful
Check Flake / check-flake (push) Successful in 3m24s

This commit is contained in:
2026-02-26 22:25:45 -08:00
parent 96d1a443b6
commit 0811dc5730

View File

@@ -22,30 +22,27 @@ in
fi 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() { verifyPIAResponse() {
local raw=$1 label=$2 local raw=$1 label=$2
local line_count trailing local total_lines
line_count=$(echo "$raw" | wc -l) total_lines=$(echo "$raw" | wc -l)
echo "DEBUG $label: response has $line_count line(s)" if echo "$raw" | jq -e . >/dev/null 2>&1; then
if [[ "$line_count" -gt 1 ]]; then echo "DEBUG $label: response is valid JSON ($total_lines lines, no trailing signature)"
trailing=$(echo "$raw" | tail -n +2)
echo "DEBUG $label: trailing data: $trailing"
else 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 fi
} }
fetchPIAToken() { fetchPIAToken() {
local PIA_USER PIA_PASS raw resp local PIA_USER PIA_PASS resp
echo "Reading PIA credentials..." echo "Reading PIA credentials..."
PIA_USER=$(sed '1q;d' /run/agenix/pia-login.conf) PIA_USER=$(sed '1q;d' /run/agenix/pia-login.conf)
PIA_PASS=$(sed '2q;d' /run/agenix/pia-login.conf) PIA_PASS=$(sed '2q;d' /run/agenix/pia-login.conf)
echo "Requesting PIA authentication token..." 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") "https://www.privateinternetaccess.com/gtoken/generateToken")
verifyPIAResponse "$raw" "generateToken"
resp=$(echo "$raw" | head -n 1)
PIA_TOKEN=$(echo "$resp" | jq -r '.token') PIA_TOKEN=$(echo "$resp" | jq -r '.token')
if [[ -z "$PIA_TOKEN" || "$PIA_TOKEN" == "null" ]]; then if [[ -z "$PIA_TOKEN" || "$PIA_TOKEN" == "null" ]]; then
echo "ERROR: Failed to fetch PIA token: $resp" >&2 echo "ERROR: Failed to fetch PIA token: $resp" >&2