English
tuic
TUIC v5 (sing-box's protocol/tuic on top of sing-quic/tuic): a QUIC connection that the client authenticates with keying material exported from the TLS session; then a stream per TCP connection, and UDP — as QUIC datagrams (native) or as a unidirectional stream per packet (quic).
| Crate | ours-mod-tuic, modules/protocols/tuic |
| Binary features | tuic-inbound, tuic-outbound (tuic enables both) (enables tls and ours-mod-tls/quic) |
| Crate features | none |
requires
dial, tls — as for hysteria: the socket through a Dialer, QUIC's TLS from the tls block.
provides
Provide::Blocks: inbound —tls; outbound —tls,dial.Provide::Inbound/Provide::Outbound { key: "tuic" }, the schemasinbounds.tuic,outbounds.tuic.
Syntax: tuic.
Dependencies
ours-quic, ours-quinn-ext, ours-uot, ours-tls-options, ours-bufpool, ours-api, ours-codec, bytes, arc-swap.
Design
src/protocol.rs— commands, addresses, UDP messages and fragment reassembly.src/udp.rs— the UDP relay: a flow is a session of the connection, a packet is a datagram or its own stream.src/outbound.rs—ours_quic::CONNECTIONS_PER_THREADQUIC connections per runtime thread; a new stream takes the one with fewer open streams (ours_quic::Load); when one is lost — a new one.src/inbound.rs— holds a connection's streams and packets until the client has authenticated, and closes a connection that did not manage to in time.src/options.rs.
Reload
Users reload in place, as in http. validate_hot checks the new list: an invalid one rejects the reload.
Tests
modules/protocols/tuic/tests/tuic.rs — TCP and UDP in all relay modes, a wrong password; unit tests in protocol.rs.