Skip to content

transport-xhttp ​

Xray's split HTTP transport (XHTTP) over HTTP/1.1, HTTP/2 and HTTP/3: a connection's reads and writes go in different HTTP requests. The transport.xhttp block is an extension of the sing-box schema.

Crateours-mod-transport-xhttp, modules/transports/xhttp
Binary featuretransport-xhttp
Crate featuresnone

requires ​

  • transport — extends its point.
  • tls — the tls block of the download leg (ours_tls_options::block::lowered).
  • The crate calls ours_proto::h2 (the HTTP/2 layer, not a module). Its HTTP/3 legs dial through the outbound's Connector, which vless serves with the variant quic of the point; the binary enables ours-mod-transport/quic with transport-xhttp.

provides ​

  • Provide::Block { block: "transport", key: "xhttp" }.
  • Provide::Schema { name: "transport.xhttp" } — the fields of V2RayXHTTPOptions.

Syntax: XHTTP; Xray's settings (xhttpSettings, the links' extra) are translated by the subscriptions module (src/xhttp.rs).

Dependencies ​

ours-transport-api (quic), ours-proto (h2, http1), ours-tls-options (the second leg's TLS options, block::lowered), ours-h2, ours-bufpool, ours-api, ours-codec, http, bytes, rand_core + getrandom, tokio.

Design ​

  • src/lib.rs — Config (scalar limits), MuxConfig (xmux: how streams share connections), KIND; the client's mode: auto is resolved here by Setup::reality: stream-one under REALITY, otherwise packet-up.
  • src/client.rs — the client: download and upload, leasing connections (Lease), Uploader.
  • src/server.rs — the server: assembling one stream from two ends.
  • src/split.rs — Split<E>: a connection made of a read end and a write end without an intermediate task or channel; each end hands the relay its buffers directly as the HTTP layer takes and gives them. Implements Splice.
  • src/http1.rs — HTTP/1.1 bodies; lengths and chunk lines are bounded independently.
  • src/h3.rs — an HTTP/3 request stream as the body of one exchange in both directions (RFC 9114).
  • src/meta.rs — where a request carries the session, the sequence number, the padding and, for packet-up, the packet, as Xray's splithttp places them.

Tests ​

modules/transports/xhttp/tests/: transport.rs (with tokio's test-util, ours-relay), h3.rs (HTTP/3, downloads from another server); unit tests in client.rs, server.rs, http1.rs.

GPL-3.0-or-later