Skip to main content

Module stream

Module stream 

Source
Expand description

Per-request stream framing on the edge ↔ tunnel side.

When the edge receives a request bound for our quick-tunnel hostname it opens a new bidi QUIC stream to us and writes:

  [ 6-byte protocolSignature ][ 2-byte protocolVersion ][ capnp ConnectRequest ]

We respond with the analogous frame carrying a ConnectResponse (status + headers as metadata), and then the stream becomes a byte-pumped channel for the HTTP body (or arbitrary TCP, for ConnectionType::Tcp).

Constants + helpers here mirror cloudflared/tunnelrpc/quic/protocol.go + request_server_stream.go. We are the server side of this framing because the edge is the one opening the stream — even though “server” is confusing given we initiated the QUIC connection. cloudflared calls it RequestServerStream for exactly the same reason.

Structs§

ConnectRequest
Parsed ConnectRequest. dest is a full URL on HTTP/Websocket streams (e.g. https://abc.trycloudflare.com/path?q=1) and a host:port on TCP streams.

Enums§

ConnectionType
What kind of payload the edge is asking us to serve on this stream. Mirror of quic_metadata_protocol.ConnectionType.

Constants§

DATA_STREAM_SIGNATURE
6-byte tag the edge writes first to disambiguate stream kinds. We only ever see DATA_STREAM_SIGNATURE on per-request streams. RPC_STREAM_SIGNATURE is reserved for the cloudflared-server RPC (session manager / config), which the edge does NOT open against quick tunnels.
HTTP_HEADER_KEY
HTTP_HOST_KEY
HTTP_METHOD_KEY
HTTP_STATUS_KEY
PROTOCOL_V1
Two ASCII bytes ("01"). cloudflared treats readVersion as a NO-OP for now — kept here verbatim so a future bump shows up loudly.
RPC_STREAM_SIGNATURE

Functions§

read_connect_request
Read the preamble (signature + version), assert it’s the data stream, and decode the capnp ConnectRequest that follows.
split
Wrap a quinn pair into the futures-io halves capnp + our framing code expects.
write_connect_response
Write a ConnectResponse preceded by the data-stream preamble.

Type Aliases§

MetaPair
Borrowed key/value pair for write_connect_response.