pub struct Config {
pub provider: Arc<dyn CryptoProvider>,
pub transport: TransportConfig,
pub reset_key: [u8; 32],
pub token_key: [u8; 32],
pub versions: Vec<u32>,
pub retry: bool,
pub retry_threshold: usize,
pub retry_token_lifetime: Duration,
pub new_token_lifetime: Option<Duration>,
pub cid_len: usize,
pub max_connections: usize,
pub epoch: OnceLock<Instant>,
}Expand description
Endpoint-wide configuration shared by its connections.
Fields§
§provider: Arc<dyn CryptoProvider>§transport: TransportConfig§reset_key: [u8; 32]Key for stateless reset tokens (HMAC of the connection ID).
token_key: [u8; 32]Key for Retry and NEW_TOKEN address-validation tokens.
versions: Vec<u32>Versions accepted by a server, preferred first. A client uses the first.
retry: boolServer: always validate addresses with Retry.
retry_threshold: usizeServer: send Retry once this many connections are in the handshake.
retry_token_lifetime: DurationLifetime of Retry tokens.
new_token_lifetime: Option<Duration>Server: issue NEW_TOKEN after the handshake; lifetime of those tokens.
cid_len: usizeLength of the connection IDs this endpoint issues (4..=20).
max_connections: usizeServer: most connections kept at once.
epoch: OnceLock<Instant>Time base for token ages, set by the first time value the endpoint sees.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(provider: Arc<dyn CryptoProvider>) -> Self
pub fn new(provider: Arc<dyn CryptoProvider>) -> Self
A configuration with random keys from the provider and default settings.
Examples found in repository?
32fn pair(real: bool) -> (Pair, ConnHandle, ConnHandle) {
33 let (cp, sp) = providers(real);
34 let mut c = Config::new(cp);
35 let mut s = Config::new(sp);
36 for x in [&mut c, &mut s] {
37 x.transport.max_data = 16 << 20;
38 x.transport.stream_window_bidi_local = 8 << 20;
39 x.transport.stream_window_bidi_remote = 8 << 20;
40 x.transport.send_buffer = 8 << 20;
41 }
42 let mut p = Pair::new(Arc::new(c), Arc::new(s), link(), 7);
43 p.batch = 16;
44 let ch = p.connect();
45 assert!(p.run_until(Duration::from_secs(10), |p| p.client.conn(ch).is_some_and(|c| c.is_established())
46 && p.server_conn().and_then(|s| p.server.conn(s)).is_some_and(|c| c.is_established())));
47 let sh = p.server_conn().unwrap();
48 p.run_for(Duration::from_millis(50));
49 (p, ch, sh)
50}Sourcepub fn reset_token(&self, cid: &[u8]) -> [u8; 16]
pub fn reset_token(&self, cid: &[u8]) -> [u8; 16]
The stateless reset token for a connection ID (RFC 9000 §10.3.2).