Skip to main content

Module l4

Module l4 

Source
Available on crate feature gateway-api only.
Expand description

TLS, TCP and UDP listeners: TLSRoutes (passthrough by SNI, or terminated with the listener’s certificates), TCPRoutes and UDPRoutes. A connection (or a UDP client’s datagrams) goes to one route — the one whose hostname best matches the SNI, else the oldest — and to a backend of its first rule by weight; bytes are relayed both ways.

Enums§

Hello
What the start of a TLS connection says.

Constants§

UDP_IDLE
How long a UDP client’s session lives without traffic.

Functions§

client_hello
Read the ClientHello at the start of bytes.
pick_endpoint
An endpoint of the route’s first rule with backends, by weight; None when there is nothing to send to.
pick_route
The route a connection goes to: the best hostname match for sni (a route without hostnames matches anything, below any hostname match), ties to the oldest route, then namespace/name.
serve_tcp
A TCPRoute connection: straight to a backend.
serve_tls_passthrough
A passthrough TLSRoute connection: read the ClientHello for its SNI, then replay it to the backend and relay the encrypted stream.
serve_tls_terminate
A terminated TLSRoute connection: handshake with the listener’s certificates, then relay the plaintext.
serve_udp
A UDPRoute listener: each client address gets its own socket to a backend (picked once), replies go back from the listener’s socket; sessions end after UDP_IDLE without traffic — or with the port: they’re in a JoinSet this task owns, so dropping it (the port given up) aborts them and releases the socket at once.