Skip to content

Issue #33 follow-ups: enum-based remotes, conn cap, UDP alloc, parser rewrite - #35

Merged
guyte149 merged 2 commits into
masterfrom
chore/issue-33-followups
May 3, 2026
Merged

Issue #33 follow-ups: enum-based remotes, conn cap, UDP alloc, parser rewrite#35
guyte149 merged 2 commits into
masterfrom
chore/issue-33-followups

Conversation

@guyte149

@guyte149 guyte149 commented May 3, 2026

Copy link
Copy Markdown
Owner

Closes #33.

Addresses every bullet from the follow-ups roll-up. Primarily an internal refactor; the only externally-visible additions are a new --max-connections flag and a wire-format version bump that requires client and server to upgrade together.

Summary

Made with Cursor

guyte149 and others added 2 commits May 3, 2026 12:57
Closes the bullets from issue #33:

- RemoteRequest is now an unambiguous tagged enum (Direction + RemoteKind
  with Tcp / Udp / Socks5 variants). Server and client dispatch collapse
  to flat match arms with no string sentinels. Wire-format break — bumps
  to 0.4.0.
- Adds --max-connections N server flag backed by a tokio::sync::Semaphore
  permit held for the lifetime of handle_client_connection. Surplus
  connections are refused at the QUIC layer rather than queued.
- UDP forward client uses bytes::Bytes channels fed from a rolling
  BytesMut arena (split_to(n).freeze() is zero-copy), eliminating the
  per-datagram Vec allocation.
- RemoteRequest::from_str rewritten as a layered parser
  (direction → protocol → tokens → kind) with per-arity helpers.
- Documents the decision to leave clippy::expect_used / panic un-denied.

Co-authored-by: Cursor <cursoragent@cursor.com>
The previous helper bound to `:0`, recorded the kernel-assigned port,
dropped the listener, and returned the number. Under CI parallelism two
sibling tests in the same binary could observe the same port number, the
first to bind would win, the second's silent `bind` failure caused a
SOCKS5 handshake to land on a plain TCP listener (the listener's `read`
returned `[5, 1, 0]`).

Replace it with a process-wide monotonic counter (`AtomicU32::fetch_add`)
in the 40_000-60_000 range, PID-seeded so parallel `cargo test`
invocations don't collide. The counter alone guarantees no in-process
duplicate; a follow-up bind probe still rules out ports a different
process on the host happens to hold. Stress-tested 15× clean (was
~6/10 failing before).

Co-authored-by: Cursor <cursoragent@cursor.com>
@guyte149
guyte149 merged commit 4c7e1b7 into master May 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from review issues #17 / #19 / #21 / #22

1 participant