Stop a .strm growing on every boot, and let TorrServer come back - #41
Merged
Merged
Conversation
TWO DEFECTS FOUND WHILE RESEARCHING SOMETHING ELSE, both verified on the live box. A legacy .strm grew by one token per restart. The startup sweep decided a file was already signed with strings.Contains(cur, "?t="), and the legacy /proxy/stream route spells its token "&t=" because that URL already carries a query (?link=...&index=...). So the file never looked signed, was re-signed on every boot, and the token was APPENDED rather than replaced. One file on the live box had the same 43-character token nine times over. The check parses the URL and asks for a "t" parameter now, and signing sets it instead of appending — which also REPAIRS a file that has already grown, because Query() collapses the repeats and Encode() writes one. The grown file fixes itself on the next start rather than needing to be found by hand. This was mine, introduced in 0.7.0 along with the legacy re-signing. TorrServer could not recover from a clean exit. Its unit used Restart=on-failure, and TorrServer exposes an HTTP /shutdown that exits 0 — which systemd reads as success, so it never restarted. Nothing else noticed either: vpntorrent/watchdog.sh clears its strike counter for a down TorrServer with the comment "TS down/restarting — systemd Restart= handles it". It does not, and the box was left with no streaming engine until a person looked. That is not hypothetical: it is exactly what happened when a probe hit /shutdown during the research. Restart=always. An explicit systemctl stop is still respected — systemd does not fight a deliberate stop — so the only behaviour that changes is the one that was broken. Both regressions are pinned, and both tests were confirmed red against the old behaviour first.
Merged
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.
Two defects found while researching something else. Both verified on the live box.
A legacy
.strmgrew by one token per restartThe startup sweep decided a file was already signed with:
The legacy
/proxy/streamroute spells its token&t=, because that URL already carries a query (?link=…&index=…). So the file never looked signed, was re-signed on every boot, and the token was appended rather than replaced. One file on the live box had the same 43-character token nine times.The check now parses the URL and asks for a
tparameter, and signing sets instead of appending — which also repairs a file that has already grown, becauseQuery()collapses the repeats andEncode()writes one. The grown file fixes itself on the next start rather than needing to be found by hand.This one was mine, introduced in 0.7.0 alongside the legacy re-signing.
TorrServer could not recover from a clean exit
Its unit used
Restart=on-failure, and TorrServer exposes an HTTP/shutdownthat exits 0 — which systemd reads as success, so it never restarted.Nothing else noticed either.
vpntorrent/watchdog.shclears its strike counter for a down TorrServer with the comment "TS down/restarting — systemd Restart= handles it". It does not, and the box was left with no streaming engine until a person looked.Not hypothetical: that is exactly what happened when a research probe hit
/shutdown.Now
Restart=always. An explicitsystemctl stopis still respected — systemd does not fight a deliberate stop — so the only behaviour that changes is the one that was broken.Tests
Both pinned, and both confirmed red against the old behaviour first: the token test asserts re-signing is idempotent and that an already-grown URL collapses to one token while keeping
linkandindexintact; the harness asserts the unit saysRestart=alwaysand noton-failure.