Skip to content

transport-http ​

The V2Ray HTTP transport: HTTP/1.1 camouflage, HTTP/1.1 tunnels and multiplexed HTTP/2 bodies. A registration only: its HTTP/2 layer (the connection, flow control, keepalive, gRPC-lite framing) lives in ours-proto under the h2 feature (crates/proto/src/h2/) and is shared with transport-grpc and transport-xhttp.

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

requires ​

transport — extends its point.

provides ​

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

Syntax: HTTP.

Dependencies ​

ours-transport-api, ours-proto (feature h2), ours-config, ours-api.

Design ​

  • src/lib.rs — KIND and MODULE; everything else is in ours-proto (crates/proto/src/h2/).
  • src/h2/mod.rs (ours-proto) — Config (the block), Options (the checked parameters; Options::grpc is the form of a gRPC-lite request on the same layer), Client (reusable HTTP/2 sessions or transparent HTTP/1.1), Server (HTTP/1.1 and HTTP/2 with prior knowledge), H2Io (the server's connection as HTTP/2 reads it).
  • Session modes (SessionMode). A session is driven by one task; its streams and its TLS stay on one core at both ends. PerShard (the default) keeps one session per shard, keyed by the shard's OS thread, so a shard's streams do not move between threads. Shared keeps one per outbound. PerStream does not share a busy session; a session beyond the first is held only by its own streams and closes with a GOAWAY together with the last of them. SessionMode::resolve maps the deprecated session_per_shard/share_session.
  • src/h2/tunnel.rs (ours-proto) — an HTTP/2 stream as a duplex byte stream (raw or as gRPC-lite messages); writes are handed to the connection in pooled buffers as they are, reading gives out what the connection received; Tunnel implements Splice.
  • src/h2/grpc.rs (ours-proto) — gRPC-lite framing: every message is protobuf field 1 of type bytes.
  • src/h2/keepalive.rs (ours-proto) — an HTTP/2 ping when reading is idle; the connection keeps being polled while it waits for the pong.

Tests ​

modules/transports/http/tests/transport.rs; unit tests in crates/proto/src/h2/grpc.rs.

GPL-3.0-or-later