diff --git a/iroh-net/src/magicsock.rs b/iroh-net/src/magicsock.rs index 49300b116b..a6237fef9f 100644 --- a/iroh-net/src/magicsock.rs +++ b/iroh-net/src/magicsock.rs @@ -66,13 +66,13 @@ const ENDPOINTS_FRESH_ENOUGH_DURATION: Duration = Duration::from_secs(27); const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5); #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub(self) enum CurrentPortFate { +enum CurrentPortFate { Keep, Drop, } #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub(self) enum Network { +enum Network { Ipv4, Ipv6, } @@ -87,7 +87,7 @@ impl From for Network { } impl Network { - pub(self) fn default_addr(&self) -> IpAddr { + fn default_addr(&self) -> IpAddr { match self { Self::Ipv4 => Ipv4Addr::UNSPECIFIED.into(), Self::Ipv6 => Ipv6Addr::UNSPECIFIED.into(), @@ -95,7 +95,7 @@ impl Network { } #[cfg(test)] - pub(self) fn local_addr(&self) -> IpAddr { + fn local_addr(&self) -> IpAddr { match self { Self::Ipv4 => Ipv4Addr::LOCALHOST.into(), Self::Ipv6 => Ipv6Addr::LOCALHOST.into(), @@ -169,23 +169,23 @@ impl Default for Options { /// possible. #[derive(Clone, Debug)] pub struct MagicSock { - pub(self) inner: Arc, + inner: Arc, // Empty when closed actor_tasks: Arc>>>, } /// The actual implementation of `MagicSock`. #[derive(derive_more::Debug)] -pub(self) struct Inner { +struct Inner { actor_sender: mpsc::Sender, /// Sends network messages. network_sender: mpsc::Sender>, - pub(self) name: String, + name: String, #[allow(clippy::type_complexity)] #[debug("on_endpoints: Option>")] on_endpoints: Option>, #[debug("on_derp_active: Option>")] - pub(self) on_derp_active: Option>, + on_derp_active: Option>, /// A callback that provides a `config::NetInfo` when discovered network conditions change. #[debug("on_net_info: Option>")] on_net_info: Option>, @@ -194,10 +194,10 @@ pub(self) struct Inner { network_recv_ch: flume::Receiver, /// Stores wakers, to be called when derp_recv_ch receives new data. network_recv_wakers: std::sync::Mutex>, - pub(self) network_send_wakers: std::sync::Mutex>, + network_send_wakers: std::sync::Mutex>, /// Key for this node. - pub(self) secret_key: SecretKey, + secret_key: SecretKey, /// Cached version of the Ipv4 and Ipv6 addrs of the current connection. local_addrs: std::sync::RwLock<(SocketAddr, Option)>, @@ -210,10 +210,10 @@ pub(self) struct Inner { /// Close was called. closed: AtomicBool, /// If the last netcheck report, reports IPv6 to be available. - pub(self) ipv6_reported: Arc, + ipv6_reported: Arc, /// None (or zero regions/nodes) means DERP is disabled. - pub(self) derp_map: Option, + derp_map: Option, /// Nearest DERP region ID; 0 means none/unknown. my_derp: AtomicU16, } @@ -222,37 +222,37 @@ impl Inner { /// Returns the derp region we are connected to, that has the best latency. /// /// If `0`, then we are not connected to any derp region. - pub(self) fn my_derp(&self) -> u16 { + fn my_derp(&self) -> u16 { self.my_derp.load(Ordering::Relaxed) } /// Sets the derp region with the best latency. /// /// If we are not connected to any derp regions, set this to `0`. - pub(self) fn set_my_derp(&self, my_derp: u16) { + fn set_my_derp(&self, my_derp: u16) { self.my_derp.store(my_derp, Ordering::Relaxed); } /// Returns `true` if we have DERP configuration for the given DERP `region`. - pub(self) async fn has_derp_region(&self, region: u16) -> bool { + async fn has_derp_region(&self, region: u16) -> bool { match &self.derp_map { None => false, Some(ref derp_map) => derp_map.contains_region(region), } } - pub(self) async fn get_derp_region(&self, region: u16) -> Option { + async fn get_derp_region(&self, region: u16) -> Option { match &self.derp_map { None => None, Some(ref derp_map) => derp_map.get_region(region).cloned(), } } - pub(self) fn is_closing(&self) -> bool { + fn is_closing(&self) -> bool { self.closing.load(Ordering::Relaxed) } - pub(self) fn is_closed(&self) -> bool { + fn is_closed(&self) -> bool { self.closed.load(Ordering::SeqCst) } @@ -607,8 +607,8 @@ impl MagicSock { /// node. In the case of shared nodes and users switching accounts, two /// nodes in the NetMap may legitimately have the same DiscoKey. As /// such, no fields in here should be considered node-specific. -pub(self) struct DiscoInfo { - pub(self) node_key: PublicKey, +struct DiscoInfo { + node_key: PublicKey, /// The precomputed key for communication with the peer that has the `node_key` used to /// look up this `DiscoInfo` in MagicSock.discoInfo. /// Not modified once initialized. @@ -818,7 +818,7 @@ impl Drop for WgGuard { #[derive(Debug)] #[allow(clippy::large_enum_variant)] -pub(self) enum ActorMessage { +enum ActorMessage { TrackedEndpoints(sync::oneshot::Sender>), LocalEndpoints(sync::oneshot::Sender>), GetMappingAddr(PublicKey, sync::oneshot::Sender>), @@ -2380,7 +2380,7 @@ fn log_endpoint_change(endpoints: &[config::Endpoint]) { /// Addresses to which to which we can send. This is either a UDP or a derp address. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub(self) enum SendAddr { +enum SendAddr { /// UDP, the ip addr. Udp(SocketAddr), /// Derp, region id. @@ -2388,18 +2388,18 @@ pub(self) enum SendAddr { } impl SendAddr { - pub(self) fn is_derp(&self) -> bool { + fn is_derp(&self) -> bool { matches!(self, Self::Derp(_)) } - pub(self) fn as_udp(&self) -> Option<&SocketAddr> { + fn as_udp(&self) -> Option<&SocketAddr> { match self { Self::Derp(_) => None, Self::Udp(addr) => Some(addr), } } - pub(self) fn derp_region(&self) -> Option { + fn derp_region(&self) -> Option { match self { Self::Derp(region) => Some(*region), Self::Udp(_) => None, @@ -2407,7 +2407,7 @@ impl SendAddr { } /// Returns the mapped version or the actual `SocketAddr`. - pub(self) fn as_socket_addr(&self) -> SocketAddr { + fn as_socket_addr(&self) -> SocketAddr { match self { Self::Derp(region) => SocketAddr::new(DERP_MAGIC_IP, *region), Self::Udp(addr) => *addr,