English
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.
| Crate | ours-mod-transport-xhttp, modules/transports/xhttp |
| Binary feature | transport-xhttp |
| Crate features | none |
requires
transport— extends its point.tls— thetlsblock of thedownloadleg (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'sConnector, whichvlessserves with the variantquicof the point; the binary enablesours-mod-transport/quicwithtransport-xhttp.
provides
Provide::Block { block: "transport", key: "xhttp" }.Provide::Schema { name: "transport.xhttp" }— the fields ofV2RayXHTTPOptions.
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'smode: autois resolved here bySetup::reality:stream-oneunder REALITY, otherwisepacket-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. ImplementsSplice.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, forpacket-up, the packet, as Xray'ssplithttpplaces 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.