Skip to content

refactor(iroh-net): portmapper and network monitor are crates #2855

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 34 commits into from
Oct 29, 2024

Conversation

divagant-martian
Copy link
Contributor

@divagant-martian divagant-martian commented Oct 28, 2024

Description

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

Breaking Changes

Full cargo public-api diff report
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

  • 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

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@@ -341,7 +339,7 @@ pub async fn default_route_interface() -> Option<String> {
/// Likely IPs of the residentla router, and the ip address of the current
/// machine using it.
#[derive(Debug, Clone)]
pub(crate) struct HomeRouter {
pub struct HomeRouter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should look into upstreaming this HomeRouter into netdev longterm

@dignifiedquire
Copy link
Contributor

  • 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.

agreed, we should look into making this API nicer in the long run

@dignifiedquire
Copy link
Contributor

  • 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

yes, would be nice and a good start, maybe make an issue for it?

@divagant-martian divagant-martian marked this pull request as ready for review October 29, 2024 15:06
@divagant-martian divagant-martian marked this pull request as draft October 29, 2024 15:11
@divagant-martian divagant-martian marked this pull request as ready for review October 29, 2024 16:02
@divagant-martian divagant-martian requested a review from a team October 29, 2024 16:02
Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@divagant-martian divagant-martian added this pull request to the merge queue Oct 29, 2024
Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

(somewhere there's going to be an outdated comment in this review - github won't tell me where it is so i can't find it to remove it 😭 )

Merged via the queue into n0-computer:main with commit fad3e24 Oct 29, 2024
33 of 34 checks passed
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
## 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.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants