Skip to main content

Module tcp_preread

Module tcp_preread 

Source
Expand description

Pure sans-io TCP passthrough SNI-preread core (issue #1279).

SniPrereadCore decides, from the raw bytes of an inbound TLS ClientHello, which cluster a TCP passthrough connection routes to – WITHOUT terminating TLS. It performs no I/O: there is no socket, no Instant::now(), no rand, and no Arc<Mutex>. Time is injected as now: Instant parameters (Input::Bytes / Input::Timeout); routing config is injected borrowed (PrereadConfig). It never mutates, consumes, or re-serializes the caller’s buffer – byte-for-byte replay is the whole point: once routed, the shell forwards the SAME bytes verbatim to the backend, starting at Output::Routed::content_offset.

Mirrors the split already established by crate::protocol::udp: a near-stateless core (decided latch + deadline, see SniPrereadCore) driven by Input / Output through SniPrereadCore::handle_input, with the accumulating byte buffer owned by the I/O shell (shell::SniPreread, wired into the session lifecycle by lib/src/tcp.rs) rather than by the core itself – every Input::Bytes carries the FULL accumulated window from wire offset 0, not a delta.

[parser] owns the nom-based wire format (TLS record layer, ClientHello, and extensions); this module owns the PROXY-v2 stripping, the SNI/ALPN routing decision against crate::router::pattern_trie::TrieNode, and the decided/deadline state machine.

Modules§

shell
I/O shell wiring the sans-io SniPrereadCore into the TCP session lifecycle (issue #1279).

Structs§

PrereadConfig
Routing input, borrowed for the lifetime of one SniPrereadCore::handle_input call. 't is the lifetime of the route table itself (owned by the listener config, well outside any single preread attempt).
SniPrereadCore
The pure preread core. Deliberately near-stateless: the shell owns the growing byte accumulator and re-feeds the FULL window on every Input::Bytes; this struct only remembers whether a terminal verdict has already been latched (decided) and when the preread deadline was armed (deadline).

Enums§

AlpnMatcher
How a route entry’s cluster accepts the client’s ALPN offer.
Input
One input fed into SniPrereadCore::handle_input.
Output
One outcome of SniPrereadCore::handle_input.
RejectReason
Why a preread attempt was terminally rejected.