Skip to content

Commit

Permalink
refactor(iroh-net): portmapper and network monitor are crates (#2855)
Browse files Browse the repository at this point in the history
## Description

The non-controversial part of the big network-utils refactor as
described in the title.

## Breaking Changes
<details><summary>Full <code>cargo public-api</code> diff
report</summary>

```
Removed items from the public API
=================================
-pub struct iroh_net::metrics::PortmapMetrics
-pub iroh_net::metrics::PortmapMetrics::external_address_updated: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::local_port_updates: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::mapping_attempts: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::mapping_failures: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::pcp_available: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::pcp_probes: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::probes_started: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::upnp_available: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::upnp_gateway_updated: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::upnp_probes: iroh_metrics::core::Counter
-pub iroh_net::metrics::PortmapMetrics::upnp_probes_failed: iroh_metrics::core::Counter
-impl core::default::Default for iroh_net::metrics::PortmapMetrics
-impl core::default::Default for iroh_net::metrics::PortmapMetrics
-pub fn iroh_net::metrics::PortmapMetrics::default() -> Self
-pub fn iroh_net::metrics::PortmapMetrics::default() -> Self
-impl iroh_metrics::core::Metric for iroh_net::metrics::PortmapMetrics
-impl iroh_metrics::core::Metric for iroh_net::metrics::PortmapMetrics
-pub fn iroh_net::metrics::PortmapMetrics::name() -> &'static str
-pub fn iroh_net::metrics::PortmapMetrics::name() -> &'static str
-impl struct_iterable_internal::Iterable for iroh_net::metrics::PortmapMetrics
-impl struct_iterable_internal::Iterable for iroh_net::metrics::PortmapMetrics
-pub fn iroh_net::metrics::PortmapMetrics::iter<'a>(&'a self) -> alloc::vec::into_iter::IntoIter<(&'static str, &'a dyn core::any::Any)>
-pub fn iroh_net::metrics::PortmapMetrics::iter<'a>(&'a self) -> alloc::vec::into_iter::IntoIter<(&'static str, &'a dyn core::any::Any)>
-pub mod iroh_net::net
-pub mod iroh_net::net::ip
-pub struct iroh_net::net::ip::LocalAddresses
-pub iroh_net::net::ip::LocalAddresses::loopback: alloc::vec::Vec<core::net::ip_addr::IpAddr>
-pub iroh_net::net::ip::LocalAddresses::regular: alloc::vec::Vec<core::net::ip_addr::IpAddr>
-impl iroh_net::net::ip::LocalAddresses
-pub fn iroh_net::net::ip::LocalAddresses::new() -> Self
-impl core::default::Default for iroh_net::net::ip::LocalAddresses
-pub fn iroh_net::net::ip::LocalAddresses::default() -> Self
-pub const fn iroh_net::net::ip::is_unicast_link_local(addr: core::net::ip_addr::Ipv6Addr) -> bool
-pub mod iroh_net::net::netmon
-pub struct iroh_net::net::netmon::CallbackToken(_)
-pub struct iroh_net::net::netmon::Monitor
-impl iroh_net::net::netmon::Monitor
-pub async fn iroh_net::net::netmon::Monitor::network_change(&self) -> anyhow::Result<()>
-pub async fn iroh_net::net::netmon::Monitor::new() -> anyhow::Result<Self>
-pub async fn iroh_net::net::netmon::Monitor::subscribe<F>(&self, callback: F) -> anyhow::Result<iroh_net::net::netmon::CallbackToken> where F: core::ops::function::Fn(bool) -> futures_lite::future::Boxed<()> + 'static + core::marker::Sync + core::marker::Send
-pub async fn iroh_net::net::netmon::Monitor::unsubscribe(&self, token: iroh_net::net::netmon::CallbackToken) -> anyhow::Result<()>
-impl core::ops::drop::Drop for iroh_net::net::netmon::Monitor
-pub fn iroh_net::net::netmon::Monitor::drop(&mut self)
-pub enum iroh_net::net::IpFamily
-pub iroh_net::net::IpFamily::V4
-pub iroh_net::net::IpFamily::V6
-impl iroh_net::net::IpFamily
-pub fn iroh_net::net::IpFamily::local_addr(&self) -> core::net::ip_addr::IpAddr
-pub fn iroh_net::net::IpFamily::unspecified_addr(&self) -> core::net::ip_addr::IpAddr
-impl core::convert::From<core::net::ip_addr::IpAddr> for iroh_net::net::IpFamily
-pub fn iroh_net::net::IpFamily::from(value: core::net::ip_addr::IpAddr) -> Self
-impl core::convert::From<iroh_net::net::IpFamily> for socket2::Domain
-pub fn socket2::Domain::from(value: iroh_net::net::IpFamily) -> Self
-pub struct iroh_net::net::UdpSocket(_)
-impl iroh_net::net::UdpSocket
-pub fn iroh_net::net::UdpSocket::bind(network: iroh_net::net::IpFamily, port: u16) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_full(addr: impl core::convert::Into<core::net::socket_addr::SocketAddr>) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_local(network: iroh_net::net::IpFamily, port: u16) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_local_v4(port: u16) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_local_v6(port: u16) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_v4(port: u16) -> anyhow::Result<Self>
-pub fn iroh_net::net::UdpSocket::bind_v6(port: u16) -> anyhow::Result<Self>
-impl core::convert::From<tokio::net::udp::UdpSocket> for iroh_net::net::UdpSocket
-pub fn iroh_net::net::UdpSocket::from(socket: tokio::net::udp::UdpSocket) -> Self
-impl core::ops::deref::Deref for iroh_net::net::UdpSocket
-pub type iroh_net::net::UdpSocket::Target = tokio::net::udp::UdpSocket
-pub fn iroh_net::net::UdpSocket::deref(&self) -> &Self::Target
-impl core::ops::drop::Drop for iroh_net::net::UdpSocket
-pub fn iroh_net::net::UdpSocket::drop(&mut self)
-impl std::os::fd::owned::AsFd for iroh_net::net::UdpSocket
-pub fn iroh_net::net::UdpSocket::as_fd(&self) -> std::os::fd::owned::BorrowedFd<'_>
-pub mod iroh_net::portmapper
-pub struct iroh_net::portmapper::Client
-impl iroh_net::portmapper::Client
-pub fn iroh_net::portmapper::Client::deactivate(&self)
-pub fn iroh_net::portmapper::Client::new(config: iroh_net::portmapper::Config) -> Self
-pub fn iroh_net::portmapper::Client::probe(&self) -> tokio::sync::oneshot::Receiver<anyhow::Result<iroh_net::portmapper::ProbeOutput, alloc::string::String>>
-pub fn iroh_net::portmapper::Client::procure_mapping(&self)
-pub fn iroh_net::portmapper::Client::update_local_port(&self, local_port: core::num::nonzero::NonZeroU16)
-pub fn iroh_net::portmapper::Client::watch_external_address(&self) -> tokio::sync::watch::Receiver<core::option::Option<core::net::socket_addr::SocketAddrV4>>
-impl core::default::Default for iroh_net::portmapper::Client
-pub fn iroh_net::portmapper::Client::default() -> Self
-pub struct iroh_net::portmapper::Config
-pub iroh_net::portmapper::Config::enable_nat_pmp: bool
-pub iroh_net::portmapper::Config::enable_pcp: bool
-pub iroh_net::portmapper::Config::enable_upnp: bool
-impl core::default::Default for iroh_net::portmapper::Config
-pub fn iroh_net::portmapper::Config::default() -> Self
-pub struct iroh_net::portmapper::Metrics
-pub iroh_net::portmapper::Metrics::external_address_updated: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::local_port_updates: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::mapping_attempts: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::mapping_failures: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::pcp_available: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::pcp_probes: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::probes_started: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::upnp_available: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::upnp_gateway_updated: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::upnp_probes: iroh_metrics::core::Counter
-pub iroh_net::portmapper::Metrics::upnp_probes_failed: iroh_metrics::core::Counter
-pub struct iroh_net::portmapper::ProbeOutput
-pub iroh_net::portmapper::ProbeOutput::nat_pmp: bool
-pub iroh_net::portmapper::ProbeOutput::pcp: bool
-pub iroh_net::portmapper::ProbeOutput::upnp: bool
-impl iroh_net::portmapper::ProbeOutput
-pub fn iroh_net::portmapper::ProbeOutput::all_available(&self) -> bool
-pub struct iroh_net::portmapper::Service

Changed items in the public API
===============================
-pub async fn iroh_net::netcheck::Client::get_report(&mut self, dm: iroh_net::relay::RelayMap, stun_conn4: core::option::Option<alloc::sync::Arc<iroh_net::net::UdpSocket>>, stun_conn6: core::option::Option<alloc::sync::Arc<iroh_net::net::UdpSocket>>) -> anyhow::Result<alloc::sync::Arc<iroh_net::netcheck::Report>>
+pub async fn iroh_net::netcheck::Client::get_report(&mut self, dm: iroh_net::relay::RelayMap, stun_conn4: core::option::Option<alloc::sync::Arc<netwatch::udp::UdpSocket>>, stun_conn6: core::option::Option<alloc::sync::Arc<netwatch::udp::UdpSocket>>) -> anyhow::Result<alloc::sync::Arc<iroh_net::netcheck::Report>>
-pub async fn iroh_net::netcheck::Client::get_report_channel(&mut self, dm: iroh_net::relay::RelayMap, stun_conn4: core::option::Option<alloc::sync::Arc<iroh_net::net::UdpSocket>>, stun_conn6: core::option::Option<alloc::sync::Arc<iroh_net::net::UdpSocket>>) -> anyhow::Result<tokio::sync::oneshot::Receiver<anyhow::Result<alloc::sync::Arc<iroh_net::netcheck::Report>>>>
+pub async fn iroh_net::netcheck::Client::get_report_channel(&mut self, dm: iroh_net::relay::RelayMap, stun_conn4: core::option::Option<alloc::sync::Arc<netwatch::udp::UdpSocket>>, stun_conn6: core::option::Option<alloc::sync::Arc<netwatch::udp::UdpSocket>>) -> anyhow::Result<tokio::sync::oneshot::Receiver<anyhow::Result<alloc::sync::Arc<iroh_net::netcheck::Report>>>>
-pub fn iroh_net::netcheck::Client::new(port_mapper: core::option::Option<iroh_net::portmapper::Client>, dns_resolver: iroh_net::dns::DnsResolver) -> anyhow::Result<Self>
+pub fn iroh_net::netcheck::Client::new(port_mapper: core::option::Option<portmapper::Client>, dns_resolver: hickory_resolver::async_resolver::TokioAsyncResolver) -> anyhow::Result<Self>
-pub iroh_net::netcheck::Report::portmap_probe: core::option::Option<iroh_net::portmapper::ProbeOutput>
+pub iroh_net::netcheck::Report::portmap_probe: core::option::Option<portmapper::ProbeOutput>

Added items to the public API
=============================
+pub use iroh_net::metrics::PortmapMetrics

```

</details>

- `iroh_net::net` is removed. The unchanged functionality can be found
in the published crate `netwatch` which the `n0 team` will keep
maintaining. This has been moved to allow serving a more general public.
- `iroh_net::portmapper` is removed. The unchanged functionality can be
found in the published crate `portmapper` which the `n0 team` will keep
maintaining. This has been moved to allow serving a more general public.
- The origin of `iroh_net::metrics::PortmapMetrics` is changed. The type
is no longer internal to `iroh-net` but re-exported from `portmapper`
- Some `netcheck` functions now require `netwatcher` and `portmapper`
parameters that are _not_ currently re-exported. `netcheck` will be
moved to it's own crate as well so this intermediate state is acceptable
for the time being

## Notes & open questions

- **what used to be called net** 
has a very small API that might not be as useful to the general public.
It only gives a `subscribe` to changes that only reports if the change
"is major" without any description of what being major is or the origin
of the change. Providing a more detailed API and better docs is
something we can do later, but it's worth noticing.
- **portmapper** 
might be good to start doing the move to `thiserror` here since it's
very clearly isolated. Maybe turn on/off as features specific protocols.
All this, again, to make it more attractive/useful to a wider audience.
- there is `netwatcher`, which I found by looking for what I thought was
a natural name to this (`netwatch`) and it has the API I'd imagine this
crate should provide. https://crates.io/crates/netwatcher

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
  • Loading branch information
divagant-martian authored Oct 29, 2024
1 parent fe684c2 commit fad3e24
Show file tree
Hide file tree
Showing 54 changed files with 301 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
# uses: obi1kenobi/cargo-semver-checks-action@v2
uses: n0-computer/cargo-semver-checks-action@feat-baseline
with:
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper
baseline-rev: ${{ env.HEAD_COMMIT_SHA }}
use-cache: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
SCCACHE_CACHE_SIZE: "50G"
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router"
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper"
IROH_FORCE_STAGING_RELAYS: "1"

jobs:
Expand Down
62 changes: 61 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ members = [
"iroh-net/bench",
"iroh-cli",
"iroh-router",
"net-tools/netwatch",
"net-tools/portmapper",
]
resolver = "2"

Expand Down
1 change: 1 addition & 0 deletions iroh-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ iroh-metrics = { version = "0.27.0" }
parking_lot = "0.12.1"
pkarr = { version = "2.2.0", default-features = false }
portable-atomic = "1"
portmapper = { version = "0.1.0", path = "../net-tools/portmapper" }
postcard = "1.0.8"
quic-rpc = { version = "0.12", features = ["flume-transport", "quinn-transport"] }
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion iroh-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use iroh::{
endpoint::{self, Connection, ConnectionTypeStream, RecvStream, RemoteInfo, SendStream},
key::{PublicKey, SecretKey},
metrics::MagicsockMetrics,
netcheck, portmapper,
netcheck,
relay::{RelayMap, RelayMode, RelayUrl},
ticket::NodeTicket,
Endpoint, NodeAddr, NodeId,
Expand Down
9 changes: 5 additions & 4 deletions iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ workspace = true

[dependencies]
anyhow = { version = "1" }
base64 = "0.22.1"
backoff = "0.4.0"
base64 = "0.22.1"
bytes = "1.7"
netdev = "0.30.0"
der = { version = "0.7", features = ["alloc", "derive"] }
derive_more = { version = "1.0.0", features = ["debug", "display", "from", "try_into", "deref"] }
futures-buffered = "0.2.8"
Expand All @@ -40,11 +39,14 @@ hyper-util = "0.1.1"
igd-next = { version = "0.15.1", features = ["aio_tokio"] }
iroh-base = { version = "0.27.0", features = ["key"] }
libc = "0.2.139"
netdev = "0.30.0"
netwatch = { version = "0.1.0", path = "../net-tools/netwatch" }
num_enum = "0.7"
once_cell = "1.18.0"
parking_lot = "0.12.1"
pin-project = "1"
pkarr = { version = "2", default-features = false, features = ["async", "relay"] }
portmapper = { path = "../net-tools/portmapper" }
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
quinn = { package = "iroh-quinn", version = "0.11" }
quinn-proto = { package = "iroh-quinn-proto", version = "0.11" }
Expand All @@ -63,10 +65,10 @@ thiserror = "1"
time = "0.3.20"
tokio = { version = "1", features = ["io-util", "macros", "sync", "rt", "net", "fs", "io-std", "signal", "process"] }
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "ring"] }
tokio-stream = { version = "0.1.15" }
tokio-tungstenite = "0.21"
tokio-tungstenite-wasm = "0.3"
tokio-util = { version = "0.7.12", features = ["io-util", "io", "codec", "rt"] }
tokio-stream = { version = "0.1.15" }
tracing = "0.1"
tungstenite = "0.21"
url = { version = "2.4", features = ["serde"] }
Expand Down Expand Up @@ -114,7 +116,6 @@ ntest = "0.9"
pretty_assertions = "1.4"
proptest = "1.2.0"
rand_chacha = "0.3.1"
testdir = "0.9.1"
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
iroh-test = "0.27.0"
Expand Down
9 changes: 0 additions & 9 deletions iroh-net/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,9 @@ pub(crate) mod timeouts {
/// The amount of time we wait for a hairpinned packet to come back.
pub(crate) const HAIRPIN_CHECK_TIMEOUT: Duration = Duration::from_millis(100);

/// Maximum duration a UPnP search can take before timing out.
pub(crate) const UPNP_SEARCH_TIMEOUT: Duration = Duration::from_secs(1);

/// Timeout to receive a response from a PCP server.
pub(crate) const PCP_RECV_TIMEOUT: Duration = Duration::from_millis(500);

/// Default Pinger timeout
pub(crate) const DEFAULT_PINGER_TIMEOUT: Duration = Duration::from_secs(5);

/// Timeout to receive a response from a NAT-PMP server.
pub(crate) const NAT_PMP_RECV_TIMEOUT: Duration = Duration::from_millis(500);

/// Timeouts specifically used in the iroh-relay
pub(crate) mod relay {
use super::*;
Expand Down
2 changes: 0 additions & 2 deletions iroh-net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,8 @@ pub mod dns;
pub mod endpoint;
mod magicsock;
pub mod metrics;
pub mod net;
pub mod netcheck;
pub mod ping;
pub mod portmapper;
pub mod relay;
pub mod stun;
pub mod ticket;
Expand Down
4 changes: 2 additions & 2 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use futures_lite::{FutureExt, Stream, StreamExt};
use futures_util::stream::BoxStream;
use iroh_base::key::NodeId;
use iroh_metrics::{inc, inc_by};
use netwatch::{interfaces, ip::LocalAddresses, netmon};
use quinn::AsyncUdpSocket;
use rand::{seq::SliceRandom, Rng, SeedableRng};
use smallvec::{smallvec, SmallVec};
Expand Down Expand Up @@ -64,8 +65,7 @@ use crate::{
dns::DnsResolver,
endpoint::NodeAddr,
key::{PublicKey, SecretKey, SharedSecret},
net::{interfaces, ip::LocalAddresses, netmon},
netcheck, portmapper,
netcheck,
relay::{RelayMap, RelayUrl},
stun, AddrInfo,
};
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
};

use iroh_metrics::inc;
use netwatch::ip::is_unicast_link_local;
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc;
use tracing::{debug, event, info, instrument, trace, warn, Level};
Expand All @@ -22,7 +23,6 @@ use crate::{
endpoint::AddrInfo,
key::PublicKey,
magicsock::{ActorMessage, MagicsockMetrics, QuicMappedAddr, Timer, HEARTBEAT_INTERVAL},
net::ip::is_unicast_link_local,
relay::RelayUrl,
stun,
util::relay_only_mode,
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/magicsock/udp_conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ use std::{
};

use anyhow::{bail, Context as _};
use netwatch::UdpSocket;
use quinn::AsyncUdpSocket;
use quinn_udp::{Transmit, UdpSockRef};
use tokio::io::Interest;
use tracing::{debug, trace};

use crate::net::UdpSocket;

/// A UDP socket implementing Quinn's [`AsyncUdpSocket`].
#[derive(Clone, Debug)]
pub struct UdpConn {
Expand Down Expand Up @@ -197,11 +196,12 @@ where
#[cfg(test)]
mod tests {
use anyhow::Result;
use netwatch::IpFamily;
use tokio::sync::mpsc;
use tracing::{info_span, Instrument};

use super::*;
use crate::{key, net::IpFamily, tls};
use crate::{key, tls};

const ALPN: &[u8] = b"n0/test/1";

Expand Down
7 changes: 3 additions & 4 deletions iroh-net/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Co-locating all of the iroh-net metrics structs
pub use portmapper::Metrics as PortmapMetrics;

#[cfg(feature = "iroh-relay")]
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "iroh-relay")))]
pub use crate::relay::server::Metrics as RelayMetrics;
pub use crate::{
magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics,
portmapper::Metrics as PortmapMetrics,
};
pub use crate::{magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics};
10 changes: 4 additions & 6 deletions iroh-net/src/netcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ use std::{

use anyhow::{anyhow, Context as _, Result};
use bytes::Bytes;
use hickory_resolver::TokioAsyncResolver as DnsResolver;
use iroh_metrics::inc;
use netwatch::{IpFamily, UdpSocket};
use tokio::{
sync::{self, mpsc, oneshot},
time::{Duration, Instant},
};
use tokio_util::{sync::CancellationToken, task::AbortOnDropHandle};
use tracing::{debug, error, info_span, trace, warn, Instrument};

use super::{portmapper, relay::RelayMap, stun};
use crate::{
dns::DnsResolver,
net::{IpFamily, UdpSocket},
relay::RelayUrl,
};
use super::{relay::RelayMap, stun};
use crate::relay::RelayUrl;

mod metrics;
mod reportgen;
Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/netcheck/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::{

use anyhow::{anyhow, bail, Context, Result};
use iroh_metrics::inc;
use netwatch::{interfaces, UdpSocket};
use rand::seq::IteratorRandom;
use tokio::{
sync::{mpsc, oneshot},
Expand All @@ -39,10 +40,8 @@ use super::NetcheckMetrics;
use crate::{
defaults::DEFAULT_STUN_PORT,
dns::{DnsResolver, ResolverExt},
net::{interfaces, UdpSocket},
netcheck::{self, Report},
ping::{PingError, Pinger},
portmapper,
relay::{RelayMap, RelayNode, RelayUrl},
stun,
util::MaybeFuture,
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/netcheck/reportgen/hairpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};

use anyhow::{bail, Context, Result};
use netwatch::UdpSocket;
use tokio::{sync::oneshot, time::Instant};
use tokio_util::task::AbortOnDropHandle;
use tracing::{debug, error, info_span, trace, warn, Instrument};

use crate::{
defaults::timeouts::HAIRPIN_CHECK_TIMEOUT,
net::UdpSocket,
netcheck::{self, reportgen, Inflight},
stun,
};
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/netcheck/reportgen/probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use std::{collections::BTreeSet, fmt, sync::Arc};

use anyhow::{ensure, Result};
use netwatch::interfaces;
use tokio::time::Duration;

use crate::{
net::interfaces,
netcheck::Report,
relay::{RelayMap, RelayNode, RelayUrl},
};
Expand Down
Loading

0 comments on commit fad3e24

Please sign in to comment.