1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! The multi-connection endpoint: one socket, many QUIC connections.
//!
//! An [`Endpoint`] owns a [`udp::Socket`](crate::udp::Socket) and routes
//! every received datagram to the connection its destination connection id
//! names: dials share the socket with accepted connections, which is what
//! lets one worker socket carry a relay's inbound sessions and its upstream
//! cluster dials at once. A single demux task receives; each connection keeps
//! a driver task of its own for timers and egress.
//!
//! Every connection id this endpoint issues is [`CID_LEN`] bytes, which is
//! what lets a short header (which does not encode the id's length) be
//! parsed at all. Ids rotate as peers consume them (`NEW_CONNECTION_ID`), so
//! a migrating client stays routable; an Initial for an unsupported version
//! gets a version negotiation packet back.
//!
//! The socket is the endpoint's identity. Its worker is where the demux and
//! every connection driver run, whichever thread built the endpoint. A socket
//! adopted as a member of a steered `SO_REUSEPORT` group (one worker per core
//! on one port; see [`udp::Bound`](crate::udp::Bound)) brings its slot along,
//! and every id the endpoint issues then carries the
//! [`moq_sock::shard::cid_prefix`] steering byte, so the kernel keeps
//! delivering a connection's packets to the worker that owns it. Dials
//! through the endpoint carry it too, which is what steers a cluster peer's
//! responses back to the dialing worker.
use server;
pub use Endpoint;
/// Every connection id this endpoint issues is this long: long enough to be
/// unguessable per socket, and fixed because a short header does not encode
/// the id's length, so parsing one assumes it.
pub const CID_LEN: usize = 8;
/// What an endpoint serves, beyond dialing.
/// A fresh [`CID_LEN`]-byte connection id, leading with the steering prefix
/// when the endpoint's socket is a member of a reuseport group.
pub