English
ours-transport-api
crates/transport-api — the contract between a protocol and the transport under it (VLESS, Trojan over WebSocket, HTTP Upgrade, HTTP, gRPC, XHTTP): the transport turns one connection into the protocol's byte stream, hiding its frames, and the protocol writes and reads bytes and knows nothing about the transport. Protocols and transport modules depend on this crate, not on the transport module, which only owns the point and the transport over QUIC (transport).
| Crate | ours-transport-api, crates/transport-api |
| Features | quic — QuicConnection and QuicSession carry ours-quic types (without it QuicConnection is uninhabited); the only one that takes ours-quic |
Contents
ClientTransport::connectgets a connection already opened by the caller and does the client half of the transport;ServerTransport::acceptgets a connection accepted by the inbound (with TLS already finished, if the inbound uses it). A transport does not listen, holds no listener and does not do TLS.Setup— what the caller fixes for one outbound/inbound (TLS, REALITY, the server name, the handshake limit, theConnectorsa transport dials with on its own);Leg— another server and its TLS options;Request(the server address and early data — the protocol's first write);Connection— the stream and what the transport learned (the peer's address);Incoming— the logical streams of one connection (HTTP/2) and aDriverthat drains frames when the last owner has let go;connect_client— how a protocol opens a stream.HANDSHAKE_TIMEOUT(15 s,C.TCPTimeout),GRPC_MAX_MESSAGE_LEN(16 MiB — our limit, the reference has none),forwarded_source(the address fromX-Forwarded-For, likebadhttp.SourceAddress).variant.rs:Kind<T>— how a transport module builds both sides from its options;decode(node, &KIND)— the shared block decoder, puts aConfiguredinto the entity's blocks;client(blocks, setup, needs)/server(...)— what the protocol calls.Caps::STREAM— a stream per protocol connection; a transport that does not give what is needed is rejected at build time.Quic<L>— the transport over QUIC, the variantQUIC("quic") of the pointtransport:dial(services)gives aQuicDialer(dials HTTP/3 through a dialer with TLS options, for an outbound'sConnector),listen(listen, transport, services, tls)— aQuicListener(startwith aQuicServeper connection,close).Lis the inbound's listen options (ours_config::options::ListenOptions): the contract does not name them, the module and the protocol both do.options.rs— theV2Ray*Optionsof the sing-box form of thetransportfield.mock.rs—Identity: a transport that changes nothing (for the tests of protocols and of the interface itself).
Dependencies
ours-api, ours-clock, ours-codec, ours-json, ours-runtime (the shard of a connection), ours-tls-options (Leg), tokio; with quic — ours-quic. Not ours-config: the crate reads no configuration itself (with quic it comes in through ours-quic, which does) (tests/layers.py, CONFIG_READERS).
Tests
tests/identity.rs — a protocol-like exchange over Identity on a real pair of sockets; unit tests in lib.rs, variant.rs.