Skip to content

Commit fad3e24

Browse files
refactor(iroh-net): portmapper and network monitor are crates (#2855)
## 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.
1 parent fe684c2 commit fad3e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+301
-76
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
# uses: obi1kenobi/cargo-semver-checks-action@v2
191191
uses: n0-computer/cargo-semver-checks-action@feat-baseline
192192
with:
193-
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router
193+
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper
194194
baseline-rev: ${{ env.HEAD_COMMIT_SHA }}
195195
use-cache: false
196196

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
RUSTFLAGS: -Dwarnings
2424
RUSTDOCFLAGS: -Dwarnings
2525
SCCACHE_CACHE_SIZE: "50G"
26-
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router"
26+
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper"
2727
IROH_FORCE_STAGING_RELAYS: "1"
2828

2929
jobs:

Cargo.lock

Lines changed: 61 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ members = [
99
"iroh-net/bench",
1010
"iroh-cli",
1111
"iroh-router",
12+
"net-tools/netwatch",
13+
"net-tools/portmapper",
1214
]
1315
resolver = "2"
1416

iroh-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ iroh-metrics = { version = "0.27.0" }
4646
parking_lot = "0.12.1"
4747
pkarr = { version = "2.2.0", default-features = false }
4848
portable-atomic = "1"
49+
portmapper = { version = "0.1.0", path = "../net-tools/portmapper" }
4950
postcard = "1.0.8"
5051
quic-rpc = { version = "0.12", features = ["flume-transport", "quinn-transport"] }
5152
rand = "0.8.5"

iroh-cli/src/commands/doctor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use iroh::{
3737
endpoint::{self, Connection, ConnectionTypeStream, RecvStream, RemoteInfo, SendStream},
3838
key::{PublicKey, SecretKey},
3939
metrics::MagicsockMetrics,
40-
netcheck, portmapper,
40+
netcheck,
4141
relay::{RelayMap, RelayMode, RelayUrl},
4242
ticket::NodeTicket,
4343
Endpoint, NodeAddr, NodeId,

iroh-net/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ workspace = true
1717

1818
[dependencies]
1919
anyhow = { version = "1" }
20-
base64 = "0.22.1"
2120
backoff = "0.4.0"
21+
base64 = "0.22.1"
2222
bytes = "1.7"
23-
netdev = "0.30.0"
2423
der = { version = "0.7", features = ["alloc", "derive"] }
2524
derive_more = { version = "1.0.0", features = ["debug", "display", "from", "try_into", "deref"] }
2625
futures-buffered = "0.2.8"
@@ -40,11 +39,14 @@ hyper-util = "0.1.1"
4039
igd-next = { version = "0.15.1", features = ["aio_tokio"] }
4140
iroh-base = { version = "0.27.0", features = ["key"] }
4241
libc = "0.2.139"
42+
netdev = "0.30.0"
43+
netwatch = { version = "0.1.0", path = "../net-tools/netwatch" }
4344
num_enum = "0.7"
4445
once_cell = "1.18.0"
4546
parking_lot = "0.12.1"
4647
pin-project = "1"
4748
pkarr = { version = "2", default-features = false, features = ["async", "relay"] }
49+
portmapper = { path = "../net-tools/portmapper" }
4850
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
4951
quinn = { package = "iroh-quinn", version = "0.11" }
5052
quinn-proto = { package = "iroh-quinn-proto", version = "0.11" }
@@ -63,10 +65,10 @@ thiserror = "1"
6365
time = "0.3.20"
6466
tokio = { version = "1", features = ["io-util", "macros", "sync", "rt", "net", "fs", "io-std", "signal", "process"] }
6567
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "ring"] }
68+
tokio-stream = { version = "0.1.15" }
6669
tokio-tungstenite = "0.21"
6770
tokio-tungstenite-wasm = "0.3"
6871
tokio-util = { version = "0.7.12", features = ["io-util", "io", "codec", "rt"] }
69-
tokio-stream = { version = "0.1.15" }
7072
tracing = "0.1"
7173
tungstenite = "0.21"
7274
url = { version = "2.4", features = ["serde"] }
@@ -114,7 +116,6 @@ ntest = "0.9"
114116
pretty_assertions = "1.4"
115117
proptest = "1.2.0"
116118
rand_chacha = "0.3.1"
117-
testdir = "0.9.1"
118119
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
119120
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
120121
iroh-test = "0.27.0"

iroh-net/src/defaults.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,9 @@ pub(crate) mod timeouts {
162162
/// The amount of time we wait for a hairpinned packet to come back.
163163
pub(crate) const HAIRPIN_CHECK_TIMEOUT: Duration = Duration::from_millis(100);
164164

165-
/// Maximum duration a UPnP search can take before timing out.
166-
pub(crate) const UPNP_SEARCH_TIMEOUT: Duration = Duration::from_secs(1);
167-
168-
/// Timeout to receive a response from a PCP server.
169-
pub(crate) const PCP_RECV_TIMEOUT: Duration = Duration::from_millis(500);
170-
171165
/// Default Pinger timeout
172166
pub(crate) const DEFAULT_PINGER_TIMEOUT: Duration = Duration::from_secs(5);
173167

174-
/// Timeout to receive a response from a NAT-PMP server.
175-
pub(crate) const NAT_PMP_RECV_TIMEOUT: Duration = Duration::from_millis(500);
176-
177168
/// Timeouts specifically used in the iroh-relay
178169
pub(crate) mod relay {
179170
use super::*;

iroh-net/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,8 @@ pub mod dns;
241241
pub mod endpoint;
242242
mod magicsock;
243243
pub mod metrics;
244-
pub mod net;
245244
pub mod netcheck;
246245
pub mod ping;
247-
pub mod portmapper;
248246
pub mod relay;
249247
pub mod stun;
250248
pub mod ticket;

iroh-net/src/magicsock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use futures_lite::{FutureExt, Stream, StreamExt};
3535
use futures_util::stream::BoxStream;
3636
use iroh_base::key::NodeId;
3737
use iroh_metrics::{inc, inc_by};
38+
use netwatch::{interfaces, ip::LocalAddresses, netmon};
3839
use quinn::AsyncUdpSocket;
3940
use rand::{seq::SliceRandom, Rng, SeedableRng};
4041
use smallvec::{smallvec, SmallVec};
@@ -64,8 +65,7 @@ use crate::{
6465
dns::DnsResolver,
6566
endpoint::NodeAddr,
6667
key::{PublicKey, SecretKey, SharedSecret},
67-
net::{interfaces, ip::LocalAddresses, netmon},
68-
netcheck, portmapper,
68+
netcheck,
6969
relay::{RelayMap, RelayUrl},
7070
stun, AddrInfo,
7171
};

iroh-net/src/magicsock/node_map/node_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66
};
77

88
use iroh_metrics::inc;
9+
use netwatch::ip::is_unicast_link_local;
910
use serde::{Deserialize, Serialize};
1011
use tokio::sync::mpsc;
1112
use tracing::{debug, event, info, instrument, trace, warn, Level};
@@ -22,7 +23,6 @@ use crate::{
2223
endpoint::AddrInfo,
2324
key::PublicKey,
2425
magicsock::{ActorMessage, MagicsockMetrics, QuicMappedAddr, Timer, HEARTBEAT_INTERVAL},
25-
net::ip::is_unicast_link_local,
2626
relay::RelayUrl,
2727
stun,
2828
util::relay_only_mode,

iroh-net/src/magicsock/udp_conn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ use std::{
99
};
1010

1111
use anyhow::{bail, Context as _};
12+
use netwatch::UdpSocket;
1213
use quinn::AsyncUdpSocket;
1314
use quinn_udp::{Transmit, UdpSockRef};
1415
use tokio::io::Interest;
1516
use tracing::{debug, trace};
1617

17-
use crate::net::UdpSocket;
18-
1918
/// A UDP socket implementing Quinn's [`AsyncUdpSocket`].
2019
#[derive(Clone, Debug)]
2120
pub struct UdpConn {
@@ -197,11 +196,12 @@ where
197196
#[cfg(test)]
198197
mod tests {
199198
use anyhow::Result;
199+
use netwatch::IpFamily;
200200
use tokio::sync::mpsc;
201201
use tracing::{info_span, Instrument};
202202

203203
use super::*;
204-
use crate::{key, net::IpFamily, tls};
204+
use crate::{key, tls};
205205

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

iroh-net/src/metrics.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Co-locating all of the iroh-net metrics structs
2+
pub use portmapper::Metrics as PortmapMetrics;
3+
24
#[cfg(feature = "iroh-relay")]
35
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "iroh-relay")))]
46
pub use crate::relay::server::Metrics as RelayMetrics;
5-
pub use crate::{
6-
magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics,
7-
portmapper::Metrics as PortmapMetrics,
8-
};
7+
pub use crate::{magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics};

iroh-net/src/netcheck.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ use std::{
1515

1616
use anyhow::{anyhow, Context as _, Result};
1717
use bytes::Bytes;
18+
use hickory_resolver::TokioAsyncResolver as DnsResolver;
1819
use iroh_metrics::inc;
20+
use netwatch::{IpFamily, UdpSocket};
1921
use tokio::{
2022
sync::{self, mpsc, oneshot},
2123
time::{Duration, Instant},
2224
};
2325
use tokio_util::{sync::CancellationToken, task::AbortOnDropHandle};
2426
use tracing::{debug, error, info_span, trace, warn, Instrument};
2527

26-
use super::{portmapper, relay::RelayMap, stun};
27-
use crate::{
28-
dns::DnsResolver,
29-
net::{IpFamily, UdpSocket},
30-
relay::RelayUrl,
31-
};
28+
use super::{relay::RelayMap, stun};
29+
use crate::relay::RelayUrl;
3230

3331
mod metrics;
3432
mod reportgen;

iroh-net/src/netcheck/reportgen.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::{
2626

2727
use anyhow::{anyhow, bail, Context, Result};
2828
use iroh_metrics::inc;
29+
use netwatch::{interfaces, UdpSocket};
2930
use rand::seq::IteratorRandom;
3031
use tokio::{
3132
sync::{mpsc, oneshot},
@@ -39,10 +40,8 @@ use super::NetcheckMetrics;
3940
use crate::{
4041
defaults::DEFAULT_STUN_PORT,
4142
dns::{DnsResolver, ResolverExt},
42-
net::{interfaces, UdpSocket},
4343
netcheck::{self, Report},
4444
ping::{PingError, Pinger},
45-
portmapper,
4645
relay::{RelayMap, RelayNode, RelayUrl},
4746
stun,
4847
util::MaybeFuture,

iroh-net/src/netcheck/reportgen/hairpin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
1616

1717
use anyhow::{bail, Context, Result};
18+
use netwatch::UdpSocket;
1819
use tokio::{sync::oneshot, time::Instant};
1920
use tokio_util::task::AbortOnDropHandle;
2021
use tracing::{debug, error, info_span, trace, warn, Instrument};
2122

2223
use crate::{
2324
defaults::timeouts::HAIRPIN_CHECK_TIMEOUT,
24-
net::UdpSocket,
2525
netcheck::{self, reportgen, Inflight},
2626
stun,
2727
};

iroh-net/src/netcheck/reportgen/probes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
use std::{collections::BTreeSet, fmt, sync::Arc};
88

99
use anyhow::{ensure, Result};
10+
use netwatch::interfaces;
1011
use tokio::time::Duration;
1112

1213
use crate::{
13-
net::interfaces,
1414
netcheck::Report,
1515
relay::{RelayMap, RelayNode, RelayUrl},
1616
};

0 commit comments

Comments
 (0)