@@ -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 {
0 commit comments