Repository navigation
fix(pia): request port-forwarding tokens from PIA's v2 endpoint - #214
Merged
Merged
Conversation
added 2 commits
October 12, 2026 13:28
After a container recreate on 2026-10-12, every token request failed for over an hour and the port-forwarding-lost alert fired. The tunnel was fine; PIA's legacy /gtoken/generateToken endpoint was answering HTTP 500 "all APIs down; please report bug" on most calls. The v2 endpoint, /api/client/v2/token, which PIA's own manual-connections get_token.sh uses, issued tokens normally, and getSignature accepts them (verified live from inside the container). transmission-post-start.sh now: - asks v2 first, with form-field credentials, and falls back to the legacy endpoint; - retries each token request, which covers curl's transient set including HTTP 500; - logs the HTTP status and PIA's message, or curl's own error. The old code sent stderr to /dev/null and could only log "network or auth". pia-pf-probe.sh switches to v2 too, so an outage like this one does not make every region probe as token_failed.
curl's --form reads a value starting with @ or < from a file and treats ;type= as a field modifier, so a PIA password containing those characters would break the v2 token request. --form-string sends the value as-is. Verified live: v2 still returns HTTP 200. Also correct the probe's comment and README paragraph claiming the credentials stay out of the process table. They appear in the host's podman exec argv and in curl's argv inside the container.
twistedmelonman
force-pushed
the
claude/fix-pia-token-endpoint
branch
from
October 12, 2026 20:28
1b3c28a to
8ea6af5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On 2026-10-12, after a container recreate at 11:33, pia-port-watchdog sent
its "port forwarding lost" alert. The tunnel was healthy, and the guard kept
the existing peer port, so downloads continued unforwarded. Every token
request failed for over an hour.
The cause was PIA's legacy
/gtoken/generateTokenendpoint. On most calls itanswered HTTP 500 with
"server error: all APIs down; please report bug". Thev2 endpoint
/api/client/v2/token, which PIA's ownpia-foss/manual-connections/get_token.shuses, issued tokens normally.Changes
transmission-post-start.shasks v2 first, with--form-stringcredentials, and falls back to the legacy endpoint.
--retry 3). curl's retry set includes HTTP 500.message, or curl's ownerror. The old code sent stderr to
/dev/nulland could only log "networkor auth".
pia-pf-probe.shuses v2 too, so an outage like this one does not makeevery region probe as
token_failed.It also corrects a claim that probe credentials stay out of the process
table; they do not.
change. They are fixed, because the commit hook lints whole files.
Verification
failing, network error,
--form-stringcredentials, and retry. All failagainst the old code and pass against the new code.
and
getSignatureaccepted a v2 token (status OK, port assigned).-S infoand shfmt are clean.Deploy
The running container does not pick this up until the setup script
redeploys
transmission-post-start.shand the container is recreated.Not done
RETURNtrap for the curl stderr temp file. The file leaks only if thefunction is interrupted mid-request.
exposure is the same as before this change.