Skip to content

ours-quic ​

crates/quic — QUIC endpoints of the hysteria, hysteria2 and tuic proxy protocols: the UDP socket a connection runs on (through the proxy's dialer and under the protocol's obfuscation), and the listener an inbound accepts on.

Contents ​

  • the crate root names what the protocols take from quinn: Connection, SendStream, RecvStream, Endpoint, the client, server, endpoint and transport configurations, VarInt, IdleTimeout, ZeroRttAccepted, the errors (SendDatagramError, ConnectionError, WriteError, ReadError, ReadToEndError, TransportErrorCode), and congestion (CubicConfig, BbrConfig, NewRenoConfig). They are quinn's own types: no crate but this one and ours-quinn-ext depends on quinn, the workspace's fork (tests/layers.py).
  • endpoint — dial(dialer, metadata, obfs) → Dialed: the dialer's own UDP socket or the packet stream of its detour; connect, connect_early (0-RTT); listen(udp, config, obfs); client_config/server_config/transport (rustls + quinn); server_name; parse_ports (Hysteria's server_ports: a port or first:last); hopping — changing the server port every interval…interval_max (hysteria.NewHopConn).
  • tls — the contract of QUIC TLS (QuicTls: client, client_chrome, server from the options of a tls block) and its service Factory (Factory::of(services)), which the tls module publishes with its quic feature; the configurations come back opaque — ClientTls (rustls' or Chrome's hello, the name quinn connects by, config(transport)) and ServerTls (without_early_data, config(transport)), so no module names rustls or ours-mod-tls for QUIC.
  • socket::Tunnel — a UDP socket for quinn on top of another outbound's packet stream; socket also names what such a socket implements (AsyncUdpSocket, UdpPoller, RecvMeta, Transmit, Runtime, TokioRuntime), for DNS's own.
  • server — what QUIC inbounds share: Listen (options, bind) and Running — the shards' UDP sockets, handed over across reload. A connection is served by the least loaded shard, not by the one on whose socket the reuseport hash dropped it: quinn drives a connection where it was accepted, so the inbound hands ours_runtime::balance::spawn the whole connection task, starting with accept; only reading datagrams stays on the socket's shard. See Runtime.
  • stream — a stream for the relay: read in pieces that quinn holds, written with relay buffers (WriteForm::Owned: a buffer filled at least halfway is handed to quinn without a copy and lives until acknowledged), counted — a stream counted in its connection's Load on the client.

Why in crates/ ​

Dialing goes through ours_api::udp::UdpDialer, which ours-mod-dial implements, and the code is shared by the three QUIC protocols and, for TLS and types, by tls, transport, dns and xhttp. The QUIC parts that know nothing about proxying are in ours-quinn-ext.

Who uses it ​

ours-mod-hysteria, ours-mod-hysteria2, ours-mod-tuic; tls — ours-mod-tls (feature quic, the implementation), ours-mod-transport (quic), ours-mod-dns (quic, h3); the types — also ours-transport-api (quic), ours-mod-transport-xhttp.

Specifics ​

Depends on quinn, quinn-proto, rustls, ring, rand_core + getrandom, bytes, tokio, ours-api, ours-config, ours-runtime, ours-bufpool, ours-codec, ours-net-sys, ours-quinn-ext, ours-tls13, ours-tls-options (the options QuicTls takes).

Tests ​

None of its own; it is checked by the tests of the three modules and tests/interop/protocols_singbox.py.

GPL-3.0-or-later