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/// Contains all timeouts that we use in `iroh`.
26#[cfg(not(wasm_browser))]
27pub mod timeouts {
28 use n0_future::time::Duration;
29
30 /// Timeout used by the relay client while connecting to the relay server,
31 /// using `TcpStream::connect`
32 pub(crate) const DIAL_ENDPOINT_TIMEOUT: Duration = Duration::from_millis(1500);
33
34 /// Happy Eyeballs (RFC 8305) Connection Attempt Delay: the maximum time to
35 /// wait before starting the next connection attempt. A faster failure
36 /// starts the next attempt immediately.
37 pub(crate) const CONNECTION_ATTEMPT_DELAY: Duration = Duration::from_millis(250);
38
39 /// Happy Eyeballs (RFC 8305) Resolution Delay: when the non-preferred
40 /// address family resolves first, wait this long for the preferred family
41 /// before starting to connect, so the preference is honored.
42 pub(crate) const RESOLUTION_DELAY: Duration = Duration::from_millis(50);
43
44 /// Default timeout for DNS queries issued by [`DnsResolver`].
45 ///
46 /// [`DnsResolver`]: iroh_dns::dns::DnsResolver
47 pub(crate) const DNS_TIMEOUT: Duration = Duration::from_secs(3);
48
49 /// Maximum time the server will attempt to get a successful write to the connection.
50 #[cfg(feature = "server")]
51 pub const SERVER_WRITE_TIMEOUT: Duration = Duration::from_secs(2);
52}