English
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), andcongestion(CubicConfig,BbrConfig,NewRenoConfig). They are quinn's own types: no crate but this one andours-quinn-extdepends 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 itsdetour;connect,connect_early(0-RTT);listen(udp, config, obfs);client_config/server_config/transport(rustls + quinn);server_name;parse_ports(Hysteria'sserver_ports: a port orfirst:last);hopping— changing the server port everyinterval…interval_max(hysteria.NewHopConn).tls— the contract of QUIC TLS (QuicTls:client,client_chrome,serverfrom the options of atlsblock) and its serviceFactory(Factory::of(services)), which thetlsmodule publishes with itsquicfeature; the configurations come back opaque —ClientTls(rustls' or Chrome's hello, the name quinn connects by,config(transport)) andServerTls(without_early_data,config(transport)), so no module names rustls orours-mod-tlsfor QUIC.socket::Tunnel— a UDP socket for quinn on top of another outbound's packet stream;socketalso names what such a socket implements (AsyncUdpSocket,UdpPoller,RecvMeta,Transmit,Runtime,TokioRuntime), for DNS's own.server— what QUIC inbounds share:Listen(options,bind) andRunning— 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 handsours_runtime::balance::spawnthe whole connection task, starting withaccept; 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'sLoadon 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.