iroh_relay/defaults.rs
1//! Default values used in the relay.
2
3/// The default QUIC port used by the Relay server to accept QUIC connections
4/// for QUIC address discovery
5///
6/// The port is "QUIC" typed on a phone keypad.
7pub const DEFAULT_RELAY_QUIC_PORT: u16 = 7842;
8
9/// The default HTTP port used by the Relay server.
10pub const DEFAULT_HTTP_PORT: u16 = 80;
11
12/// The default HTTPS port used by the Relay server.
13pub const DEFAULT_HTTPS_PORT: u16 = 443;
14
15/// The default metrics port used by the Relay server.
16pub const DEFAULT_METRICS_PORT: u16 = 9090;
17
18/// The default capacity of the key cache for the relay server.
19///
20/// Sized for 1 million concurrent clients.
21/// memory usage will be (32 + 8 + 8 + 8) * 1_000_000 = 56MB on 64 bit,
22/// which seems reasonable for a server.
23pub const DEFAULT_KEY_CACHE_CAPACITY: usize = 1024 * 1024;
24
25/// Listen backlog when none is configured.
26/// Tokio and std default to 128, which
27/// overflows under bursts of slow handshakes.
28#[cfg(feature = "server")]
29pub(crate) const DEFAULT_LISTEN_BACKLOG: u32 = 1024;
30
31/// Contains all timeouts that we use in `iroh`.
32#[cfg(not(wasm_browser))]
33pub mod timeouts {
34 use n0_future::time::Duration;
35
36 /// Timeout used by the relay client while connecting to the relay server,
37 /// using `TcpStream::connect`
38 pub(crate) const DIAL_ENDPOINT_TIMEOUT: Duration = Duration::from_millis(1500);
39
40 /// Happy Eyeballs (RFC 8305) Connection Attempt Delay: the maximum time to
41 /// wait before starting the next connection attempt. A faster failure
42 /// starts the next attempt immediately.
43 pub(crate) const CONNECTION_ATTEMPT_DELAY: Duration = Duration::from_millis(250);
44
45 /// Happy Eyeballs (RFC 8305) Resolution Delay: when the non-preferred
46 /// address family resolves first, wait this long for the preferred family
47 /// before starting to connect, so the preference is honored.
48 pub(crate) const RESOLUTION_DELAY: Duration = Duration::from_millis(50);
49
50 /// Default timeout for DNS queries issued by [`DnsResolver`].
51 ///
52 /// [`DnsResolver`]: iroh_dns::dns::DnsResolver
53 pub(crate) const DNS_TIMEOUT: Duration = Duration::from_secs(3);
54
55 /// Maximum time the server will attempt to get a successful write to the connection.
56 #[cfg(feature = "server")]
57 pub const SERVER_WRITE_TIMEOUT: Duration = Duration::from_secs(2);
58}