Expand description
Per-request HTTP/1.1 proxy: bridge an inbound capnp-framed
stream from the edge to the local TCP listener the caller
wants to expose at https://<sub>.trycloudflare.com.
Wire flow on the edge → tunnel side:
- Edge writes the data-stream preamble +
ConnectRequest(parsed bystream::read_connect_request). - We connect a TCP socket to
127.0.0.1:<local_port>and write a re-synthesised HTTP/1.1 request line +Host+ everyHttpHeader:<Name>the edge forwarded + an empty line. Body bytes (if any) follow from the QUIC stream. - We parse the HTTP/1.1 response status + headers off the
TCP socket, write them back as a
ConnectResponse(status inHttpStatus, each header inHttpHeader:<Name>), and finally byte-pump the response body from TCP to QUIC.
Mirrors cloudflared/connection/quic_connection.go
(buildHTTPRequest + httpResponseAdapter).
Structs§
- Stream
Counters - Byte counters the supervisor accumulates across all streams. Cheap atomics so the proxy task can update without coordination.
Constants§
- LOCAL_
CONNECT_ TIMEOUT - How long we wait for the local TCP listener to accept the first byte. Quick tunnels are usually pointed at a process that just finished booting; 5s is generous without making real failures drag out.
Functions§
- handle_
inbound_ stream - Drive one inbound request stream to completion. Reads the
ConnectRequestoffrecv, runs the matching proxy strategy, writes theConnectResponseback, and pumps the body bytes.