Repository navigation
feat(net): cap payload accepted before bridge hello - #111
Merged
AlxcBTW merged 2 commits intoOct 27, 2026
Merged
Conversation
AlxcBTW
requested changes
Oct 27, 2026
AlxcBTW
left a comment
Member
There was a problem hiding this comment.
Thanks fago, this is the right idea and the tests check real behaviour (small hello passes, oversized payload and oversized declared length are closed). Three things before merge:
- The limit is visible on the wire, so it belongs in
spec/bridge-protocol.md(Connection section, next to the hello description): hello payload is at most 1024 bytes, a larger first frame closes the connection. The bridge in AnyPS5 must match that file, and the token length is not fixed there today, so please state the limit explicitly. - The hand-rolled header sniffing in
serve(header_buf,header_read, the 12 + MAX_HELLO_PAYLOAD running total) duplicates the framing logic and is easy to get subtly wrong. Please move the cap into the decoder incrates/bridge-protocol(for exampleDecoder::with_max_payload(n), default MAX_PAYLOAD, returning Error::TooLarge from the header alone) and use it for the pre-hello phase, then keep the 16 MiB decoder after hello. That also covers the 'announced length' case without extra state, and gets a unit test next to the existing TooLarge tests. - Please add the boundary test: a payload of exactly MAX_HELLO_PAYLOAD bytes is accepted (or reaches the parse step), so an off-by-one cannot slip in. Also a test with the hello split over several tiny writes would be nice.
Everything else (timeout kept, Closed still reported) looks fine.
…-hello limit in spec
Contributor
Author
|
Updated per review:
|
AlxcBTW
approved these changes
Oct 27, 2026
AlxcBTW
left a comment
Member
There was a problem hiding this comment.
Thanks fago, this is exactly what I hoped for: the cap lives in the decoder, the spec documents the 1024-byte limit, and the boundary and split-write tests are there. Merging once CI is green.
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.
What and why
Caps the payload accepted before a bridge \hello\ frame in \crates/net/src/bridge.rs\ (\MAX_HELLO_PAYLOAD = 1024\ bytes).
Checklist
Need help on this PR? Tag
@codesmith-botwith what you need.