Implement the prereadable connection - #47
Open
weiiwang01 wants to merge 1 commit into
Open
Conversation
weiiwang01
marked this pull request as ready for review
August 17, 2026 06:29
weiiwang01
requested review from
swetha1654 and
yanksyoon
and removed request for
a team
August 17, 2026 06:29
There was a problem hiding this comment.
Pull request overview
Implements a new internal conn package that wraps *net.TCPConn to support a “preread” mode: reads are buffered and can be rewound/replayed so callers can sniff initial bytes (e.g., SNI/Host) without losing stream integrity.
Changes:
- Added
internal/conn.Connwith preread buffering, rewind, preread limit enforcement, and optional metrics hooks. - Added an extensive test suite covering limit behavior, replay boundaries, EOF handling, and concurrency invariants.
- Updated module Go version and dependency set.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/conn/conn.go | Adds the preread-capable TCPConn wrapper, options, and metrics hooks. |
| internal/conn/conn_test.go | Adds comprehensive unit tests for preread/replay/limit/EOF and concurrency behaviors. |
| go.mod | Updates Go version and introduces new module requirements/indirect requirements. |
| go.sum | Adds checksums for new/updated module dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if m == nil { | ||
| panic("nil metrics") | ||
| } | ||
| if v := reflect.ValueOf(m); v.Kind() == reflect.Pointer && v.IsNil() { |
Comment on lines
+3
to
4
| go 1.25.0 | ||
|
|
|
|
||
| const defaultPrereadLimit = 64 * 1024 | ||
|
|
||
| var ErrPrereadLimitExceeded = errors.New("exceed preread limit") |
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.
Stack created with GitHub Stacks CLI • Give Feedback 💬
This is a part of a series of pull requests to create the next generation of the aproxy.
In this pull request, the core utility that enables the extraction of SNI or host name from a connection (prereadable connection) is implemented.