carrier/exit: bound and pre-size relay body reads#138
Merged
Conversation
Kianmhz
pushed a commit
that referenced
this pull request
May 20, 2026
Classify dial errors from http.Client.Do separately from relay/server
failures and route them through a short 15s local-offline blacklist
instead of the 30m/1h endpoint penalty tiers. A quota-free TCP probe
to google_host:443 clears those transient backoffs when the network
returns, so airplane-mode / captive-portal / brief blackout recovery
happens in seconds rather than minutes.
Drops Linux-only syscall.ENONET from the errno set so the carrier builds
on macOS/Windows; ENONET ("machine is not on the network") is already
covered by the message-substring fallback in isLocalNetworkOffline.
The HTTP 500 mock in TestPollOnceMarksOnlyDoErrors... now sets
ContentLength: -1 so the post-#138 readRelayResponseBody treats the
body as unknown-length and reads it through (rather than honoring
the zero-valued ContentLength as "empty body").
Co-authored-by: poulcarlsen53 <poulcarlsen53@gmail.com>
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
/tunnelrequestsContent-Lengthis knownLimitedReaderfallback when length is unknown so oversized bodies are rejected without reading unbounded data/tunnelrequest bodiesWhy
This reduces avoidable large intermediate allocations on normal relay bodies and protects both sides from unexpectedly huge HTML/error/request payloads.
Verification
go test -count=1 ./internal/carrier -run TestReadRelayResponseBodyBoundsAndPreallocatesgo test -count=1 ./internal/exit -run TestReadTunnelRequestBodyBoundsAndPreallocatesgo test -count=1 ./...go vet ./...