Skip to content

Commit 20e462d

Browse files
nat traversal requires multipath (#159)
* nat traversal requires multipath * allow crate access, not ideal, but unavoidable * satisfty MSRV limits * pub all the way to the top * update wasm-bindgen-test
1 parent 85a2706 commit 20e462d

File tree

5 files changed

+61
-39
lines changed

5 files changed

+61
-39
lines changed

Cargo.lock

Lines changed: 22 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quinn-proto/src/config/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ mod transport;
3030
pub use transport::QlogConfig;
3131
pub use transport::{AckFrequencyConfig, IdleTimeout, MtuDiscoveryConfig, TransportConfig};
3232

33+
#[cfg(doc)]
34+
pub use transport::DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED;
35+
3336
/// Global configuration for the endpoint, affecting all connections
3437
///
3538
/// Default values should be suitable for most internet applications.

quinn-proto/src/config/transport.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ use crate::{
1212
congestion, connection::qlog::QlogSink,
1313
};
1414

15+
/// When multipath is required and has not been explicitly enabled, this value will be used for
16+
/// [`TransportConfig::max_concurrent_multipath_paths`].
17+
const DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED_: NonZeroU32 = {
18+
match NonZeroU32::new(4) {
19+
Some(v) => v,
20+
None => panic!("to enable multipath this must be positive, which clearly it is"),
21+
}
22+
};
23+
24+
/// When multipath is required and has not been explicitly enabled, this value will be used for
25+
///
26+
/// [`TransportConfig::max_concurrent_multipath_paths`].
27+
#[cfg(doc)]
28+
pub const DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED: NonZeroU32 =
29+
DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED_;
30+
1531
/// Parameters governing the core QUIC state machine
1632
///
1733
/// Default values should be suitable for most internet applications. Applications protocols which
@@ -432,11 +448,28 @@ impl TransportConfig {
432448
///
433449
/// Setting this to any nonzero value will enable the Nat Traversal Extension for QUIC,
434450
/// see <https://www.ietf.org/archive/id/draft-seemann-quic-nat-traversal-02.html>
451+
///
452+
/// This implementation expects the multipath extension to be enabled as well. if not yet
453+
/// enabled via [`Self::max_concurrent_multipath_paths`], a default value of
454+
/// [`DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED`] will be used.
435455
pub fn set_max_nat_traversal_concurrent_attempts(&mut self, max_concurrent: u32) -> &mut Self {
436456
self.nat_traversal_concurrency_limit = NonZeroU32::new(max_concurrent);
457+
if max_concurrent != 0 && self.max_concurrent_multipath_paths.is_none() {
458+
self.max_concurrent_multipath_paths(
459+
DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED_.get(),
460+
);
461+
}
437462
self
438463
}
439464

465+
/// Gets the maximum number of concurrent attempts for nat traversal
466+
///
467+
/// If this is `Some`, the value is guaranteed to be non zero.
468+
pub fn get_nat_traversal_concurrency_limit(&self) -> Option<VarInt> {
469+
self.nat_traversal_concurrency_limit
470+
.map(|non_zero| VarInt::from_u32(non_zero.get()))
471+
}
472+
440473
/// qlog capture configuration to use for a particular connection
441474
#[cfg(feature = "qlog")]
442475
pub fn qlog_stream(&mut self, stream: Option<QlogStream>) -> &mut Self {

quinn-proto/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pub use connection::qlog::QlogStream;
5555
pub use rustls;
5656

5757
mod config;
58+
#[cfg(doc)]
59+
pub use config::DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED;
5860
#[cfg(feature = "qlog")]
5961
pub use config::QlogConfig;
6062
pub use config::{

quinn-proto/src/transport_parameters.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ impl TransportParameters {
196196
}),
197197
address_discovery_role: config.address_discovery_role,
198198
initial_max_path_id: config.get_initial_max_path_id(),
199-
nat_traversal: config
200-
.nat_traversal_concurrency_limit
201-
.map(|limit| VarInt::from_u32(limit.get())),
199+
nat_traversal: config.get_nat_traversal_concurrency_limit(),
202200
..Self::default()
203201
}
204202
}

0 commit comments

Comments
 (0)