-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Penguin v7 #33
Penguin v7 #33
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
==========================================
+ Coverage 77.63% 78.71% +1.08%
==========================================
Files 31 30 -1
Lines 5370 5216 -154
==========================================
- Hits 4169 4106 -63
+ Misses 1201 1110 -91 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Also nice to remove UDP client ID and make that fully symmetric too. |
41d3396
to
5fd1341
Compare
e383ef7
to
3b51ffa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the protocol for Penguin v7 by revising the stream frame structure. Key changes include:
- Combining source and destination ports into a single 32-bit stream ID.
- Adding a new bind operation via a dedicated opcode.
- Changing the receive window field type from u64 to u32.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/mux/frame.rs | Refactored stream frame structure and methods to support Penguin v7. |
PROTOCOL.md | Updated protocol version and stream frame format details for v7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the protocol to "Penguin v7" by revising how streams are identified and by switching frame buffer types from 64-bit to 32-bit. Key changes include:
- Combining separate source and destination port fields into a single 16‑bit stream ID throughout the code.
- Changing internal counters and window size types from u64 to u32.
- Updating protocol documentation and error messages to reflect these changes.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/mux/test.rs | Updated logging to reflect the new stream_id field instead of separate port numbers. |
src/mux/stream.rs | Converted port-based fields to use stream_id and updated associated atomic types to u32. |
src/mux/lib.rs | Revised error types and module exports reflecting updated stream identification. |
src/mux/inner.rs | Modified stream management logic to use stream_id and updated task names and associated comments. |
src/mux/frame.rs | Adjusted frame serialization and deserialization to use stream_id and new opcode definitions. |
src/mux/config.rs | Changed RWND and threshold types from u64 to u32. |
PROTOCOL.md | Updated protocol version to v7 and modified frame format details to align with new stream_id usage. |
.github/workflows/cross-releases.yml | Enabled additional rust targets by uncommenting previously disabled targets. |
Comments suppressed due to low confidence (1)
PROTOCOL.md:115
- The protocol documentation states the stream ID is a 32-bit unsigned integer, but the implementation uses a 16-bit stream ID. Please update the documentation to accurately reflect the implementation.
frame with the `Syn` operation code and the stream ID set to a unique 32-bit unsigned integer in network byte order.
src/mux/inner.rs
Outdated
let entry = streams.get_mut(&stream_id).expect("TODO"); | ||
// Change the state of the stream to `Established` | ||
let Some(sender) = entry.establish(stream_data) else { | ||
return Err(Error::BogusSynAck); | ||
todo!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the placeholder error message 'TODO' with a descriptive message and handle the case where the stream cannot be established instead of panicking.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Change: since both the server and client might initiate multiplexed streams/datagrams, Stream ID is reverted to sport/dport to avoid race conditions. |
0c98d97
to
c250829
Compare
@@ -262,18 +244,16 @@ | |||
#[tracing::instrument(skip(self), level = "debug")] | |||
#[inline] | |||
pub async fn send_datagram(&self, frame: DatagramFrame) -> Result<()> { | |||
let payload: Bytes = Vec::<u8>::try_from(frame)?.into(); | |||
// Always flush datagrams immediately | |||
// Always flush datagrams immediately TODO |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
Signed-off-by: Zhang Maiyun <[email protected]>
There have been a few issues accumulating that requires a protocol update to implement. Planned changes:
Combine the source and destination ports (stream frame) into one 32-bit stream IDu64
tou32
Stream IDRationale
There has been no reason to have two ports like actual TCP/IP. The only purpose of this field is to uniquely identify multiplexed channel. Using a single
u16
reduces overhead and possible error conditions.Potential Considerations
The stream ID probably has to be generated by the client, since the client initiates the channel.
With two ports, each side maintains a connection hash table based on the port number, so duplicate ports never affects the other side. However, now one side is responsible for generating the stream ID, the server needs to be able to deal with ill-implemented clients generating duplicate stream IDs.
Proposed solution: once a duplicate
Syn
is detected, it isRst
ed and both the original (established) channel and this new channel are aborted.Bind
Rationale
This would allow the client to ask the server to bind to a port, which makes it possible to implement #24 and SOCKS5
BIND
.Potential Considerations
The server now needs to be able to initiate channels for incoming connections, so the code for establishing new channels needs to become symmetrical, at least more so.
32-bit rwnd
Rationale
In this implementation, the default
rwnd
has been2<<9
which is far lower than2<<63
. Usingu32
will allowpenguin
to work on platforms with noAtomicU64
.Potential Considerations
None right now.