Skip to content

Develop - #7

Open
abhishek9686 wants to merge 7 commits into
masterfrom
develop
Open

Develop#7
abhishek9686 wants to merge 7 commits into
masterfrom
develop

Conversation

@abhishek9686

Copy link
Copy Markdown
Member

No description provided.

abhishek9686 and others added 4 commits August 11, 2026 10:20
The data plane corrupted itself under load: an exit node pushes packets
from many goroutines and nothing kept two writers off one TLS connection.

- writeFrame emitted the 12-byte header and the payload as two separate
  Writes, so a concurrent writer could land between them and a write
  deadline could expire mid-frame. Either one desynchronises the peer's
  framing for the life of the connection. Build the frame in a single
  pooled buffer and emit it with one Write.
- Client.SendPacket released the mutex before writing, so DATA frames
  raced each other and the ping loop's control frames. Serialise every
  write on a dedicated writeMu, separate from mu so a stuck write cannot
  block state reads or Stop.
- Close the connection on any write error, client and server alike. A
  single Write can still flush partially, so the stream can no longer be
  framed and the peer has to reconnect instead of parsing garbage.
- Give the pre-session HELLO write a deadline as well, or a stalled
  handshake write hangs the supervisor.

Registry: add DetachSession, which drops a peer only when the caller's
session is still the registered one. A reconnecting client attaches its
new session before the old read loop finishes unwinding, so the old
session's unconditional Detach evicted the live one and left the peer
looking session-less. Add PeerIDs so a gateway can enumerate peers that
actually have a session and divert only those onto TCP.
This workflow automates the release process for the proxy Go module, allowing version tagging and GitHub Releases.
NM-295: force-close TCP uplink sessions on Server.Stop
@tenki-reviewer

tenki-reviewer Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces an uplink package: a frame.go wire layer with sync.Pool buffer reuse and big-endian header encode/decode, a client.go that manages a TLS connection with concurrent read/ping/write loops and re-HELLO on reconnect, a server.go that accepts sessions and routes packets, and a registry.go providing an in-memory session registry with attach/detach/close semantics. It also adds unit and integration tests, a CI release workflow, and README updates.

Files Change
uplink/frame.go Adds pooled frame read/write helpers with length validation and header encode/decode.
uplink/client.go Refactors the client into concurrent read/ping/write loops with mutex- and atomic-guarded state and re-HELLO on reconnect.
uplink/server.go Adds session accept/close handling and shutdown that forces clients to re-HELLO.
uplink/registry.go Adds an in-memory session registry with attach/detach/close-all lifecycle methods.
uplink/*_test.go Adds unit and integration tests for framing, registry, and client/server behavior.
.github/workflows/release.yml Adds a release workflow with semver validation, tag push, and prerelease handling.
README.md Documents the new uplink usage.

Note: a few scan passes (correctness group 0, the networking-transport and registry-lifecycle domain specialists, and the holistic pass) did not publish artifacts; the remaining passes and the verifier covered the diff.

Reviewed commit: be78b4e

abhishek9686 and others added 3 commits August 28, 2026 00:01
Replace raw TLS streaming with WebSocket (/uplink/v1), keep framed WG auth
inside binary messages, and add explicit connect/auth logs with client IP.
defaultWSPingInterval = 25s
defaultWSPongWait = 60s
Read deadline (initial + on Pong) = pingInterval + pongWait (85s by default)
NM-295: migrate TCP uplink to WSS with selfsigned and proxy TLS modes
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.

1 participant