diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 7d829e0f1..288200cf9 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -4501,7 +4501,7 @@ impl Connection { warn!(?addr, "server sent ilegal ADD_ADDRESS frame"); } - match client_state.add_remote_address(addr.clone()) { + match client_state.add_remote_address(addr) { Ok(maybe_added) => { if let Some(added) = maybe_added { self.events.push_back(Event::NatTraversal( @@ -4527,7 +4527,7 @@ impl Connection { )); }; - if let Some(removed_addr) = client_state.remove_remote_address(addr.clone()) { + if let Some(removed_addr) = client_state.remove_remote_address(addr) { self.events .push_back(Event::NatTraversal(iroh_hp::Event::AddressRemoved( removed_addr, @@ -5915,7 +5915,7 @@ impl Connection { /// This is calculated as minimum between the local and remote's maximums when multipath is /// enabled, or `None` when disabled. /// - /// For data that's received, we should use [`self.local_max_path_id`] instead. + /// For data that's received, we should use [`Self::local_max_path_id`] instead. /// The reasoning is that the remote might already have updated to its own newer /// [`Self::max_path_id`] after sending out a `MAX_PATH_ID` frame, but it got re-ordered. fn max_path_id(&self) -> Option { diff --git a/quinn-proto/src/iroh_hp.rs b/quinn-proto/src/iroh_hp.rs index c5d83b577..d9b2f37cf 100644 --- a/quinn-proto/src/iroh_hp.rs +++ b/quinn-proto/src/iroh_hp.rs @@ -1,3 +1,5 @@ +//! iroh NAT Traversal + use std::{ collections::hash_map::Entry, net::{IpAddr, SocketAddr}, @@ -56,10 +58,12 @@ pub(crate) struct RandDataNeeded { pub(crate) is_new_round: bool, } -// TODO(@divma): unclear to me what these events are useful for\ +/// Event emitted when the client receives ADD_ADDRESS or REMOVE_ADDRESS frames. #[derive(Debug, Clone)] pub enum Event { + /// An ADD_ADDRESS frame was received. AddressAdded(SocketAddr), + /// A REMOVE_ADDRESS frame was received. AddressRemoved(SocketAddr), } @@ -207,7 +211,7 @@ impl State { return Err(Error::NotEnoughAddresses); } - let prev_round_path_ids = std::mem::replace(&mut self.round_path_ids, Default::default()); + let prev_round_path_ids = std::mem::take(&mut self.round_path_ids); self.round = self.round.saturating_add(1u8); Ok(NatTraversalRound {