1- use std:: { fmt, num:: NonZeroU32 , sync:: Arc } ;
1+ use std:: {
2+ fmt,
3+ num:: { NonZeroU8 , NonZeroU32 } ,
4+ sync:: Arc ,
5+ } ;
26#[ cfg( feature = "qlog" ) ]
37use std:: { io, sync:: Mutex , time:: Instant } ;
48
@@ -15,7 +19,7 @@ use crate::{
1519/// When multipath is required and has not been explicitly enabled, this value will be used for
1620/// [`TransportConfig::max_concurrent_multipath_paths`].
1721const DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED_ : NonZeroU32 = {
18- match NonZeroU32 :: new ( 4 ) {
22+ match NonZeroU32 :: new ( 12 ) {
1923 Some ( v) => v,
2024 None => panic ! ( "to enable multipath this must be positive, which clearly it is" ) ,
2125 }
@@ -78,7 +82,7 @@ pub struct TransportConfig {
7882 pub ( crate ) default_path_max_idle_timeout : Option < Duration > ,
7983 pub ( crate ) default_path_keep_alive_interval : Option < Duration > ,
8084
81- pub ( crate ) nat_traversal_concurrency_limit : Option < NonZeroU32 > ,
85+ pub ( crate ) max_remote_nat_traversal_addresses : Option < NonZeroU8 > ,
8286
8387 pub ( crate ) qlog_sink : QlogSink ,
8488}
@@ -443,33 +447,26 @@ impl TransportConfig {
443447 . map ( Into :: into)
444448 }
445449
446- /// Sets the maximum number of concurrent nat traversal attempts to initiate as a client, or to
447- /// allow as a server.
450+ /// Sets the maximum number of nat traversal addresses this endpoint allows the remote to
451+ /// advertise
448452 ///
449- /// Setting this to any nonzero value will enable the Nat Traversal Extension for QUIC,
450- /// see <https://www.ietf.org/archive/id/draft-seemann-quic-nat-traversal-02.html>
453+ /// Setting this to any nonzero value will enable Iroh's holepunching, losely based in the Nat
454+ /// Traversal Extension for QUIC, see
455+ /// <https://www.ietf.org/archive/id/draft-seemann-quic-nat-traversal-02.html>
451456 ///
452457 /// This implementation expects the multipath extension to be enabled as well. if not yet
453458 /// enabled via [`Self::max_concurrent_multipath_paths`], a default value of
454459 /// [`DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED`] will be used.
455- pub fn set_max_nat_traversal_concurrent_attempts ( & mut self , max_concurrent : u32 ) -> & mut Self {
456- self . nat_traversal_concurrency_limit = NonZeroU32 :: new ( max_concurrent ) ;
457- if max_concurrent != 0 && self . max_concurrent_multipath_paths . is_none ( ) {
460+ pub fn set_max_remote_nat_traversal_addresses ( & mut self , max_addresses : u8 ) -> & mut Self {
461+ self . max_remote_nat_traversal_addresses = NonZeroU8 :: new ( max_addresses ) ;
462+ if max_addresses != 0 && self . max_concurrent_multipath_paths . is_none ( ) {
458463 self . max_concurrent_multipath_paths (
459464 DEFAULT_CONCURRENT_MULTIPATH_PATHS_WHEN_ENABLED_ . get ( ) ,
460465 ) ;
461466 }
462467 self
463468 }
464469
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-
473470 /// qlog capture configuration to use for a particular connection
474471 #[ cfg( feature = "qlog" ) ]
475472 pub fn qlog_stream ( & mut self , stream : Option < QlogStream > ) -> & mut Self {
@@ -526,7 +523,7 @@ impl Default for TransportConfig {
526523 default_path_keep_alive_interval : None ,
527524
528525 // nat traversal disabled by default
529- nat_traversal_concurrency_limit : None ,
526+ max_remote_nat_traversal_addresses : None ,
530527
531528 qlog_sink : QlogSink :: default ( ) ,
532529 }
@@ -565,7 +562,7 @@ impl fmt::Debug for TransportConfig {
565562 max_concurrent_multipath_paths,
566563 default_path_max_idle_timeout,
567564 default_path_keep_alive_interval,
568- nat_traversal_concurrency_limit ,
565+ max_remote_nat_traversal_addresses ,
569566 qlog_sink,
570567 } = self ;
571568 let mut s = fmt. debug_struct ( "TransportConfig" ) ;
@@ -610,8 +607,8 @@ impl fmt::Debug for TransportConfig {
610607 default_path_keep_alive_interval,
611608 )
612609 . field (
613- "nat_traversal_concurrency_limit " ,
614- nat_traversal_concurrency_limit ,
610+ "max_remote_nat_traversal_addresses " ,
611+ max_remote_nat_traversal_addresses ,
615612 ) ;
616613 if cfg ! ( feature = "qlog" ) {
617614 s. field ( "qlog_stream" , & qlog_sink. is_enabled ( ) ) ;
0 commit comments