Send the controller secret when TrafficStore polls /connections - #109
Merged
Conversation
`AppConstants.authorizedControllerRequest` exists so every REST client attaches `Authorization: Bearer <secret>` uniformly, and its doc comment says as much. `TrafficStore.fetchConnections` was the sole call site that passed a bare URL instead: nine others route through the helper. The main app always generates a controller secret, so every poll came back 401. The response body has no `connections` key, so the guard fell through to a silent `return` and the counters never left zero — the Traffic & Data tab read "Zero KB" and "0 proxy / 0 total" while the engine was moving tens of megabytes and tracking 15 live connections. Route the poll through the helper, and log a non-200 instead of discarding it silently so the next auth or address regression is visible. No test could have caught this: ProxyEngineHelper started the engine with an empty secret, so the whole integration suite exercised an open controller. It now takes a secret, and three tests cover the gap — that a protected controller refuses a bare request, that the helper's request is accepted, and that TrafficStore's own polling reports non-zero bytes end to end. That last one reproduces the "Zero KB" symptom exactly when the header is removed.
This was referenced Aug 27, 2026
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.
Problem
The Traffic & Data tab read "Zero KB" and "0 proxy / 0 total" while the engine was moving tens of megabytes. Querying the controller directly showed it healthy the whole time:
AppConstants.authorizedControllerRequestexists so every REST client attachesAuthorization: Bearer <secret>uniformly, and its doc comment says as much.TrafficStore.fetchConnectionswas the sole call site that passed a bare URL instead — nine others route through the helper.The main app always generates a controller secret, so every poll came back 401. The response body has no
connectionskey, so the guard fell through to a silentreturnand the counters never left zero.Fix
Route the poll through the helper, and log a non-200 instead of discarding it silently so the next auth or address regression is visible rather than presenting as "everything is zero".
Why no test caught it
ProxyEngineHelper.startpassed""as the controller secret, so the entire integration suite exercised an open controller and structurally could not catch a REST client that forgets the header.It now takes an optional
controllerSecret(defaulting to"", so existing callers are untouched), and three tests close the gap:authorizedControllerRequestis accepted (200)TrafficStore's own polling reports non-zero bytes end to endThat last one guards the call site rather than just the contract: removing the header makes it fail with
downloaded → 0, reproducing the reported symptom exactly.Full suite (216) green,
swiftlint --strictclean.