ADR 0003: Fate of the TCP code
Status: Accepted (maintainer decision, 2026-10-27: recommendation adopted)
Context
The initial assumption was that the TCP work (2024-04) was a failed attempt and dead code. The audit and a live test show otherwise.
Verified facts (2026-10-27):
- Upstream
hbbsalready speaks TCP and WebSocket natively (Sink::TcpStream,Sink::Ws, WebSocket on port+2, reverse-proxyX-Real-IPhandling). - Upstream
hbbshas noKeyExchangehandler insrc/. Our fork implements it (key_exchange_phase1and the phase-2 handler insrc/rendezvous_server.rs). - The upstream client has
secure_tcp, which tolerates a server without the exchange, andsecure_tcp_required, which refuses such a server so that nothing is sent in clear. - Live test: our
hbbsagainst the upstream client’skey_exchange()(copied verbatim, with the client’s exacthbb_common): the exchange succeeds at version 0, an encryptedTestNatRequestround-trips, and a wrong public key is rejected. Not tested: the full Flutter client, and upstreamhbbs. - The client’s current scheme is version 1 (signed
KxParams, transcript binding). Our server only speaks version 0 and offers no signed parameters. - Client side, our
RendezvousMediator::is_udp_disabled()readsenable-tcp-mode == "N". Upstream now has its ownis_udp_disabled()readingdisable-udp == "Y". The two switches are different options with different meanings. - Both our client (
src/common.rs) and our server (rendezvous_server.rs:570) log the session symmetric key at debug level. - Issue #16 shows users believe our “TCP mode” lets them cross an HTTPS proxy without UDP; that is a Pro-server feature.
Options
- Delete all TCP code. Breaks the
secure_tcp_requiredpath against our server; removes the only OSS server-side key exchange we know of. - Isolate behind a Cargo feature flag. Keeps the code but ships it off by default; a feature that protocol clients require should not be optional.
- Keep, modernise, and trim.
Recommendation
Option 3:
- Keep the server key exchange. Make it default-on.
- Upgrade to version 1 (signed
KxParams, transcript binding), answering version-0 clients as the legacy scheme. Depends on thehbb_commonbump from ADR 0002 and must be re-tested with the same harness against a recent client. - Remove the symmetric-key debug logs in client and server. This is independent of everything else and can ship first.
- Remove our client-side
is_udp_disabledandenable-tcp-modein favour of upstream’sdisable-udp. - Add a regression test that runs the key-exchange round-trip in CI (the harness from the audit is the seed).
- Document what “TCP mode” does and does not do, to close issue #16.
Consequences
- No behaviour is removed from servers that exist today.
- The server pins a newer
hbb_commonthan upstream’s server does; this is the cost of staying compatible with current clients. - Open: whether upstream plans its own server-side exchange. If it lands, our implementation becomes a candidate for removal; the CI round-trip test tells us when.