Skip to main content

Module shell

Module shell 

Source
Expand description

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

SniPreread is the socket-owning half of the split described in the module doc one level up: it accumulates bytes from the raw frontend socket into the session’s own Checkout (NEVER consume()d while undecided – byte-for-byte replay to the backend is the whole point), re-feeds the full accumulated window to SniPrereadCore::handle_input on every read, and – once routed – stays parked in this state through backend connect. This mirrors RelayProxyProtocol, not Pipe: Pipe::set_back_socket does not re-arm inherited buffer writes, so a premature switch to Pipe before the backend socket exists would strand the connect handshake.

This module intentionally emits its OWN tcp.sni_preread.* decision metrics (routed / rejected.) and log lines, but does not own the tcp.sni_preread.active gauge lifecycle or the eventual state transition out of SniPreread – both live in lib/src/tcp.rs (gauge: +1 on entry in TcpSession::new_sni_preread, -1 in TcpSession::upgrade_sni_preread on the upgrade exit or in TcpSession::close’s StateMarker::SniPreread arm on the reject/teardown exits; transition: TcpSession::upgrade_sni_preread), which alone has the TcpProxy/TcpListener context (per-cluster proxy_protocol, buffers, listener) needed to pick the right next state and guarantee the gauge is adjusted exactly once per session, on exactly one of its three exits (reject / upgrade / teardown).

Structs§

RoutedOutcome
Captured exactly once, when Output::Routed first fires. The core’s own decided latch guarantees the SAME terminal verdict replays on every subsequent handle_input call, so SniPreread::outcome never changes once Some.
SniPreread
TCP session state that owns the frontend socket and the accumulating Checkout while SniPrereadCore decides a route. See the module doc for the full lifecycle and the exit-accounting contract for tcp.sni_preread.active.