Skip to content
Merged
21 changes: 14 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)", "cfg(iroh_l

[workspace.lints.clippy]
unused-async = "warn"

[patch.crates-io]
noq = { git = "https://github.com/n0-computer/noq", branch = "main" }
noq-udp = { git = "https://github.com/n0-computer/noq", branch = "main" }
noq-proto = { git = "https://github.com/n0-computer/noq", branch = "main" }
4 changes: 3 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ ignore = [
]

[sources]
allow-git = []
allow-git = [
"https://github.com/n0-computer/noq",
]
18 changes: 10 additions & 8 deletions iroh/src/endpoint/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ pub use noq_proto::{
};
use tracing::warn;

use crate::socket::{HEARTBEAT_INTERVAL, MAX_MULTIPATH_PATHS, PATH_MAX_IDLE_TIMEOUT};
use crate::socket::{
HEARTBEAT_INTERVAL, MAX_MULTIPATH_PATHS, MAX_QNT_ADDRESSES, PATH_MAX_IDLE_TIMEOUT,
};

/// Builder for a [`QuicTransportConfig`].
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -111,7 +113,7 @@ pub struct QuicTransportConfigBuilder(noq::TransportConfig);
/// - [`QuicTransportConfigBuilder::default_path_keep_alive_interval`]
/// - [`QuicTransportConfigBuilder::default_path_max_idle_timeout`]
/// - [`QuicTransportConfigBuilder::max_concurrent_multipath_paths`]
/// - [`QuicTransportConfigBuilder::set_max_remote_nat_traversal_addresses`]
/// - [`QuicTransportConfigBuilder::max_remote_nat_traversal_addresses`]
///
/// # Examples
/// ```
Expand Down Expand Up @@ -154,8 +156,8 @@ impl QuicTransportConfigBuilder {
cfg.keep_alive_interval(Some(HEARTBEAT_INTERVAL));
cfg.default_path_keep_alive_interval(Some(HEARTBEAT_INTERVAL));
cfg.default_path_max_idle_timeout(Some(PATH_MAX_IDLE_TIMEOUT));
cfg.max_concurrent_multipath_paths(MAX_MULTIPATH_PATHS + 1);
cfg.set_max_remote_nat_traversal_addresses(MAX_MULTIPATH_PATHS as u8);
cfg.max_concurrent_multipath_paths(MAX_MULTIPATH_PATHS);
cfg.max_remote_nat_traversal_addresses(MAX_QNT_ADDRESSES);
Self(cfg)
}

Expand Down Expand Up @@ -528,18 +530,18 @@ impl QuicTransportConfigBuilder {
///
/// This implementation expects the multipath extension to be enabled as well. If not yet
/// enabled via [`Self::max_concurrent_multipath_paths`], a default value of
/// 12 will be used.
/// 8 will be used.
///
/// Note: this method will ignore values less than the recommended 12 and will log a warning.
pub fn set_max_remote_nat_traversal_addresses(mut self, max_addresses: u8) -> Self {
/// Note: this method will ignore values less than the recommended 8 and will log a warning.
pub fn max_remote_nat_traversal_addresses(mut self, max_addresses: u8) -> Self {
if max_addresses < MAX_MULTIPATH_PATHS as u8 {
warn!(
"QuicTransportConfig::max_remote_nat_traversal_addresses must be at least {}, ignoring user supplied value",
MAX_MULTIPATH_PATHS
);
return self;
}
self.0.set_max_remote_nat_traversal_addresses(max_addresses);
self.0.max_remote_nat_traversal_addresses(max_addresses);
self
}

Expand Down
15 changes: 13 additions & 2 deletions iroh/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,19 @@ pub(crate) const RELAY_PATH_MAX_IDLE_TIMEOUT: Duration = Duration::from_secs(30)

/// Maximum number of concurrent QUIC multipath paths per connection.
///
/// Pretty arbitrary and high right now.
pub(crate) const MAX_MULTIPATH_PATHS: u32 = 12;
/// We expect 1 relay path, and then leave space for ~3 IP and custom transport paths.
/// On top of that, when we expect a network change, we might be closing these paths
/// (except for the relay path) and open new ones, and give us 3 more paths to spare.
/// And finally we round that up to 8 for good measure.
pub(crate) const MAX_MULTIPATH_PATHS: u32 = 8;

/// Maximum number of n0 QUIC NAT Traversal addresses that the QUIC stack should allow.
///
/// This needs to be big enough to accommodate for machines which have lots of network
/// interfaces enabled. We've seen MacOS machines with >25 interfaces in the wild
/// (mostly due to VPN TUN and docket interfaces), so this seems like a reasonable
/// value.
pub(crate) const MAX_QNT_ADDRESSES: u8 = 32;

/// Error returned when the endpoint state actor stopped while waiting for a reply.
#[stack_error(add_meta, derive)]
Expand Down
Loading