Expand description
SNI-based routing for TCP TLS passthrough.
extract_sni peeks the server name out of a TLS ClientHello without
terminating TLS, so the SniRouter can pick a backend pool by hostname
and the raw bytes are relayed on to it. The parser operates on a possibly
partial, fully untrusted buffer: it is bounds-checked at every step and
never panics โ a short buffer yields SniResult::Incomplete (read
more), and anything malformed or non-ClientHello yields
SniResult::NotPresent (fall back to the default pool).
Structsยง
- SniRouter
- Routes a TCP connection to a backend pool by its ClientHello SNI hostname, falling back to a default pool.
Enumsยง
- Skip ๐
- SniPattern ๐
- An SNI match pattern: exact hostname or a single-label wildcard. Shared by the L4 stream router and the TLS multi-cert resolver.
- SniResult
- Outcome of parsing a (possibly partial) TLS record for the SNI hostname.
Constantsยง
- MAX_
RECORD_ ๐LEN - Max TLS record length per RFC (2^14 + 256 headroom); a larger declared length is treated as malformed.
Functionsยง
- advance ๐
- Advances
pbyn, orNoneif that would exceedceiling. - be16 ๐
- Big-endian
u16atbuf[p..p+2], orNoneif out of bounds. - be24 ๐
- Big-endian
u24atbuf[p..p+3], orNoneif out of bounds. - extract_
sni - Extracts the SNI hostname from the start of a TLS stream. Bounds-safe and
panic-free; see the module docs for the
SniResultcontract. - parse_
server_ ๐name - Parses the
server_nameextension body (buf[start..end]). - skip_
vec ๐ - Skips a length-prefixed vector: reads a
len_bytes-wide (1 or 2) big-endian length atp, then skips that many bytes, all bounded byceiling.