pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh_net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3139/docs/iroh_net_report/fn.os_has_ipv6.html b/pr/3139/docs/iroh_net_report/fn.os_has_ipv6.html
index e437c3c05f..ac8e9a06b8 100644
--- a/pr/3139/docs/iroh_net_report/fn.os_has_ipv6.html
+++ b/pr/3139/docs/iroh_net_report/fn.os_has_ipv6.html
@@ -1,2 +1,2 @@
-os_has_ipv6 in iroh_net_report - Rust pub fn os_has_ipv6() -> bool
Available on non-wasm_browser only.Expand description
Test if IPv6 works at all, or if it’s been hard disabled at the OS level.
+os_has_ipv6 in iroh_net_report - Rust
\ No newline at end of file
diff --git a/pr/3139/docs/iroh_net_report/index.html b/pr/3139/docs/iroh_net_report/index.html
index a0868d6fb4..bebe302d44 100644
--- a/pr/3139/docs/iroh_net_report/index.html
+++ b/pr/3139/docs/iroh_net_report/index.html
@@ -1,4 +1,4 @@
-iroh_net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh_net_report - Rust Expand description
Checks the network conditions from the current host.
NetReport is responsible for finding out the network conditions of the current host, like
whether it is connected to the internet via IPv4 and/or IPv6, what the NAT situation is
etc and reachability to the configured relays.
diff --git a/pr/3139/docs/iroh_net_report/struct.Addr.html b/pr/3139/docs/iroh_net_report/struct.Addr.html
index c3b865cbb3..6ebab178c7 100644
--- a/pr/3139/docs/iroh_net_report/struct.Addr.html
+++ b/pr/3139/docs/iroh_net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh_net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh_net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/iroh_net_report/struct.Client.html b/pr/3139/docs/iroh_net_report/struct.Client.html
index d88d444b46..7669a95f68 100644
--- a/pr/3139/docs/iroh_net_report/struct.Client.html
+++ b/pr/3139/docs/iroh_net_report/struct.Client.html
@@ -1,21 +1,21 @@
-Client in iroh_net_report - Rust pub struct Client { /* private fields */ }
Expand description
Client to run net_reports.
+Client in iroh_net_report - Rust pub struct Client { /* private fields */ }
Expand description
Client to run net_reports.
Creating this creates a net_report actor which runs in the background. Most of the time
it is idle unless Client::get_report is called, which is the main interface.
The Client struct can be cloned and results multiple handles to the running actor.
If all Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
-Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
) -> Result<Self>
Creates a new net_report client.
This starts a connected actor in the background. Once the client is dropped it will
stop running.
-Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
stun_sock_v4: Option<Arc<UdpSocket>>,
@@ -37,20 +37,20 @@ When available, the report will attempt to get an observed public address
using QUIC address discovery.
When None, it will disable the QUIC address discovery probes.
This will attempt to use all probe protocols.
-
Sourcepub async fn get_report_with_opts(
+
Sourcepub async fn get_report_with_opts(
&mut self,
relay_map: RelayMap,
opts: Options,
) -> Result<Arc<Report>>
Runs a net_report, returning the report.
It may not be called concurrently with itself, &mut self takes care of that.
Look at Options for the different configuration options.
-Sourcepub async fn get_report_channel(
+
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Client
§impl RefUnwindSafe for Client
§impl Send for Client
§impl Sync for Client
§impl Unpin for Client
§impl UnwindSafe for Client
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Client
§impl RefUnwindSafe for Client
§impl Send for Client
§impl Sync for Client
§impl Unpin for Client
§impl UnwindSafe for Client
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/iroh_net_report/struct.Options.html b/pr/3139/docs/iroh_net_report/struct.Options.html
index 894f9952c8..cac7a3f35d 100644
--- a/pr/3139/docs/iroh_net_report/struct.Options.html
+++ b/pr/3139/docs/iroh_net_report/struct.Options.html
@@ -1,15 +1,15 @@
-Options in iroh_net_report - Rust pub struct Options { /* private fields */ }
Expand description
Options for running probes
+Options in iroh_net_report - Rust pub struct Options { /* private fields */ }
Expand description
Options for running probes
By default, will run icmp over IPv4, icmp over IPv6, and Https probes.
Use Options::stun_v4, Options::stun_v6, and Options::quic_config
to enable STUN over IPv4, STUN over IPv6, and QUIC address discovery.
-Implementations§
Source§impl Options
Sourcepub fn stun_v4(self, sock: Option<Arc<UdpSocket>>) -> Self
Available on non-wasm_browser only.
Set the ipv4 stun socket and enable ipv4 stun probes
-Sourcepub fn stun_v6(self, sock: Option<Arc<UdpSocket>>) -> Self
Available on non-wasm_browser only.
Set the ipv6 stun socket and enable ipv6 stun probes
-Sourcepub fn quic_config(self, quic_config: Option<QuicConfig>) -> Self
Available on non-wasm_browser only.
Enable quic probes
-Sourcepub fn icmp_v4(self, enable: bool) -> Self
Available on non-wasm_browser only.
Enable or disable icmp_v4 probe
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Options
§impl !RefUnwindSafe for Options
§impl Send for Options
§impl Sync for Options
§impl Unpin for Options
§impl !UnwindSafe for Options
Blanket Implementations§
Implementations§
Source§impl Options
Sourcepub fn stun_v4(self, sock: Option<Arc<UdpSocket>>) -> Self
Available on non-wasm_browser only.
Set the ipv4 stun socket and enable ipv4 stun probes
+Sourcepub fn stun_v6(self, sock: Option<Arc<UdpSocket>>) -> Self
Available on non-wasm_browser only.
Set the ipv6 stun socket and enable ipv6 stun probes
+Sourcepub fn quic_config(self, quic_config: Option<QuicConfig>) -> Self
Available on non-wasm_browser only.
Enable quic probes
+Sourcepub fn icmp_v4(self, enable: bool) -> Self
Available on non-wasm_browser only.
Enable or disable icmp_v4 probe
+Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Options
§impl !RefUnwindSafe for Options
§impl Send for Options
§impl Sync for Options
§impl Unpin for Options
§impl !UnwindSafe for Options
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/iroh_net_report/struct.QuicConfig.html b/pr/3139/docs/iroh_net_report/struct.QuicConfig.html
index 6e79221683..0b446f9658 100644
--- a/pr/3139/docs/iroh_net_report/struct.QuicConfig.html
+++ b/pr/3139/docs/iroh_net_report/struct.QuicConfig.html
@@ -1,4 +1,4 @@
-QuicConfig in iroh_net_report - Rust pub struct QuicConfig {
+QuicConfig in iroh_net_report - Rust pub struct QuicConfig {
pub ep: Endpoint,
pub client_config: ClientConfig,
pub ipv4: bool,
@@ -8,7 +8,7 @@
§client_config: ClientConfigA client config.
§ipv4: boolEnable ipv4 QUIC address discovery probes
§ipv6: boolEnable ipv6 QUIC address discovery probes
-Trait Implementations§
Source§impl Clone for QuicConfig
Source§fn clone(&self) -> QuicConfig
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for QuicConfig
§impl !RefUnwindSafe for QuicConfig
§impl Send for QuicConfig
§impl Sync for QuicConfig
§impl Unpin for QuicConfig
§impl !UnwindSafe for QuicConfig
Blanket Implementations§
Source§impl<T> Any for Twhere
+Trait Implementations§
Source§impl Clone for QuicConfig
Source§fn clone(&self) -> QuicConfig
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for QuicConfig
§impl !RefUnwindSafe for QuicConfig
§impl Send for QuicConfig
§impl Sync for QuicConfig
§impl Unpin for QuicConfig
§impl !UnwindSafe for QuicConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/iroh_net_report/struct.RelayLatencies.html b/pr/3139/docs/iroh_net_report/struct.RelayLatencies.html
index 180acce980..fdca6c97bd 100644
--- a/pr/3139/docs/iroh_net_report/struct.RelayLatencies.html
+++ b/pr/3139/docs/iroh_net_report/struct.RelayLatencies.html
@@ -1,7 +1,7 @@
-RelayLatencies in iroh_net_report - Rust pub struct RelayLatencies(/* private fields */);
Expand description
Latencies per relay node.
-Implementations§
Trait Implementations§
Source§impl Clone for RelayLatencies
Source§fn clone(&self) -> RelayLatencies
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for RelayLatencies
Source§impl Default for RelayLatencies
Source§fn default() -> RelayLatencies
Returns the “default value” for a type. Read moreSource§impl PartialEq for RelayLatencies
Source§impl Eq for RelayLatencies
Source§impl StructuralPartialEq for RelayLatencies
Auto Trait Implementations§
§impl Freeze for RelayLatencies
§impl RefUnwindSafe for RelayLatencies
§impl Send for RelayLatencies
§impl Sync for RelayLatencies
§impl Unpin for RelayLatencies
§impl UnwindSafe for RelayLatencies
Blanket Implementations§
Source§impl<T> Any for Twhere
+RelayLatencies in iroh_net_report - Rust pub struct RelayLatencies(/* private fields */);
Expand description
Latencies per relay node.
+Implementations§
Trait Implementations§
Source§impl Clone for RelayLatencies
Source§fn clone(&self) -> RelayLatencies
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for RelayLatencies
Source§impl Default for RelayLatencies
Source§fn default() -> RelayLatencies
Returns the “default value” for a type. Read moreSource§impl PartialEq for RelayLatencies
Source§impl Eq for RelayLatencies
Source§impl StructuralPartialEq for RelayLatencies
Auto Trait Implementations§
§impl Freeze for RelayLatencies
§impl RefUnwindSafe for RelayLatencies
§impl Send for RelayLatencies
§impl Sync for RelayLatencies
§impl Unpin for RelayLatencies
§impl UnwindSafe for RelayLatencies
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/iroh_net_report/struct.Report.html b/pr/3139/docs/iroh_net_report/struct.Report.html
index e868cea3a7..6d4bcde3dd 100644
--- a/pr/3139/docs/iroh_net_report/struct.Report.html
+++ b/pr/3139/docs/iroh_net_report/struct.Report.html
@@ -1,4 +1,4 @@
-Report in iroh_net_report - Rust pub struct Report {Show 19 fields
+Report in iroh_net_report - Rust pub struct Report {
§hair_pinning: Option<bool>Whether the router supports communicating between two local devices through the NATted
public IP address (on IPv4).
-§portmap_probe: Option<ProbeOutput>Available on non-wasm_browser only.Probe indicating the presence of port mapping protocols on the LAN.
+§portmap_probe: Option<ProbeOutput>Probe indicating the presence of port mapping protocols on the LAN.
§preferred_relay: Option<RelayUrl>None for unknown
§relay_latency: RelayLatencieskeyed by relay Url
§relay_v4_latency: RelayLatencieskeyed by relay Url
@@ -43,8 +43,8 @@ public IP address (on IPv4).
§global_v6: Option<SocketAddrV6>[ip]:port of global IPv6
§captive_portal: Option<bool>CaptivePortal is set when we think there’s a captive portal that is
intercepting HTTP traffic.
-Trait Implementations§
Source§impl Eq for Report
Source§impl StructuralPartialEq for Report
Auto Trait Implementations§
§impl Freeze for Report
§impl RefUnwindSafe for Report
§impl Send for Report
§impl Sync for Report
§impl Unpin for Report
§impl UnwindSafe for Report
Blanket Implementations§
Source§impl<T> Any for Twhere
+Trait Implementations§
Source§impl Eq for Report
Source§impl StructuralPartialEq for Report
Auto Trait Implementations§
§impl Freeze for Report
§impl RefUnwindSafe for Report
§impl Send for Report
§impl Sync for Report
§impl Unpin for Report
§impl UnwindSafe for Report
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3139/docs/src/iroh_net_report/lib.rs.html b/pr/3139/docs/src/iroh_net_report/lib.rs.html
index 51ed1def1d..b8df76748e 100644
--- a/pr/3139/docs/src/iroh_net_report/lib.rs.html
+++ b/pr/3139/docs/src/iroh_net_report/lib.rs.html
@@ -1524,7 +1524,27 @@
1523
1524
1525
-1526
//! Checks the network conditions from the current host.
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
//! Checks the network conditions from the current host.
//!
//! NetReport is responsible for finding out the network conditions of the current host, like
//! whether it is connected to the internet via IPv4 and/or IPv6, what the NAT situation is
@@ -1569,11 +1589,32 @@
mod ping;
mod reportgen;
+/// We "vendor" what we need of the library in browsers for simplicity.
+///
+/// We could consider making `portmapper` compile to wasm in the future,
+/// but what we need is so little it's likely not worth it.
+#[cfg(wasm_browser)]
+pub mod portmapper {
+ /// Output of a port mapping probe.
+ #[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
+ #[display("portmap={{ UPnP: {upnp}, PMP: {nat_pmp}, PCP: {pcp} }}")]
+ pub struct ProbeOutput {
+ /// If UPnP can be considered available.
+ pub upnp: bool,
+ /// If PCP can be considered available.
+ pub pcp: bool,
+ /// If PMP can be considered available.
+ pub nat_pmp: bool,
+ }
+}
+
#[cfg(not(wasm_browser))]
pub use ip_mapped_addrs::{IpMappedAddr, IpMappedAddrError, IpMappedAddresses, MAPPED_ADDR_PORT};
pub use metrics::Metrics;
+use reportgen::ProbeProto;
pub use reportgen::QuicConfig;
-use reportgen::{ProbeProto, SocketState};
+#[cfg(not(wasm_browser))]
+use reportgen::SocketState;
#[cfg(feature = "stun-utils")]
pub use stun_utils::bind_local_stun_socket;
@@ -1620,7 +1661,6 @@
/// public IP address (on IPv4).
pub hair_pinning: Option<bool>,
/// Probe indicating the presence of port mapping protocols on the LAN.
- #[cfg(not(wasm_browser))]
pub portmap_probe: Option<portmapper::ProbeOutput>,
/// `None` for unknown
pub preferred_relay: Option<RelayUrl>,
diff --git a/pr/3139/docs/src/iroh_net_report/reportgen.rs.html b/pr/3139/docs/src/iroh_net_report/reportgen.rs.html
index a518480f1a..bdd8391c71 100644
--- a/pr/3139/docs/src/iroh_net_report/reportgen.rs.html
+++ b/pr/3139/docs/src/iroh_net_report/reportgen.rs.html
@@ -1736,7 +1736,26 @@
1735
1736
1737
-1738
//! The reportgen actor is responsible for generating a single net_report report.
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
//! The reportgen actor is responsible for generating a single net_report report.
//!
//! It is implemented as an actor with [`Client`] as handle.
//!
@@ -1775,6 +1794,8 @@
protos::stun,
RelayMap, RelayNode,
};
+#[cfg(wasm_browser)]
+use n0_future::future::Pending;
use n0_future::{
task::{self, AbortOnDropHandle, JoinSet},
time::{self, Duration, Instant},
@@ -1787,7 +1808,9 @@
use tracing::{debug, debug_span, error, info_span, trace, warn, Instrument, Span};
use url::Host;
-#[cfg(feature = "metrics")]
+#[cfg(wasm_browser)]
+use crate::portmapper; // We stub the library
+#[cfg(feature = "metrics")]
use crate::Metrics;
use crate::{self as net_report, Report};
#[cfg(not(wasm_browser))]
@@ -1820,8 +1843,9 @@
_drop_guard: AbortOnDropHandle<()>,
}
-#[derive(Debug, Clone)]
-pub struct SocketState {
+#[cfg(not(wasm_browser))]
+#[derive(Debug, Clone)]
+pub(crate) struct SocketState {
/// The portmapper client, if there is one.
pub(crate) port_mapper: Option<portmapper::Client>,
/// Socket to send IPv4 STUN requests from.
@@ -2201,7 +2225,14 @@
fn prepare_portmapper_task(
&mut self,
) -> MaybeFuture<Pin<Box<impl Future<Output = Option<portmapper::ProbeOutput>>>>> {
- let mut port_mapping = MaybeFuture::default();
+ // In the browser, the compiler struggles to infer the type of future inside, because it's never set.
+ #[cfg(wasm_browser)]
+ let port_mapping: MaybeFuture<Pin<Box<Pending<Option<portmapper::ProbeOutput>>>>> =
+ MaybeFuture::default();
+
+ #[cfg(not(wasm_browser))]
+ let mut port_mapping = MaybeFuture::default();
+
#[cfg(not(wasm_browser))]
if let Some(port_mapper) = self.socket_state.port_mapper.clone() {
port_mapping.inner = Some(Box::pin(async move {
@@ -2226,6 +2257,13 @@
fn prepare_captive_portal_task(
&mut self,
) -> MaybeFuture<Pin<Box<impl Future<Output = Option<bool>>>>> {
+ // In the browser case the compiler cannot infer the type of the future, because it's never set:
+ #[cfg(wasm_browser)]
+ let captive_task: MaybeFuture<Pin<Box<Pending<Option<bool>>>>> = MaybeFuture::default();
+
+ #[cfg(not(wasm_browser))]
+ let mut captive_task = MaybeFuture::default();
+
// If we're doing a full probe, also check for a captive portal. We
// delay by a bit to wait for UDP STUN to finish, to avoid the probe if
// it's unnecessary.
@@ -2241,39 +2279,37 @@
let dns_resolver = self.socket_state.dns_resolver.clone();
let dm = self.relay_map.clone();
self.outstanding_tasks.captive_task = true;
- return MaybeFuture {
- inner: Some(Box::pin(async move {
- time::sleep(CAPTIVE_PORTAL_DELAY).await;
- debug!("Captive portal check started after {CAPTIVE_PORTAL_DELAY:?}");
- let captive_portal_check = time::timeout(
- CAPTIVE_PORTAL_TIMEOUT,
- check_captive_portal(&dns_resolver, &dm, preferred_relay)
- .instrument(debug_span!("captive-portal")),
- );
- match captive_portal_check.await {
- Ok(Ok(found)) => Some(found),
- Ok(Err(err)) => {
- let err: Result<reqwest::Error, _> = err.downcast();
- match err {
- Ok(req_err) if req_err.is_connect() => {
- debug!("check_captive_portal failed: {req_err:#}");
- }
- Ok(req_err) => warn!("check_captive_portal error: {req_err:#}"),
- Err(any_err) => warn!("check_captive_portal error: {any_err:#}"),
+ captive_task.inner = Some(Box::pin(async move {
+ time::sleep(CAPTIVE_PORTAL_DELAY).await;
+ debug!("Captive portal check started after {CAPTIVE_PORTAL_DELAY:?}");
+ let captive_portal_check = time::timeout(
+ CAPTIVE_PORTAL_TIMEOUT,
+ check_captive_portal(&dns_resolver, &dm, preferred_relay)
+ .instrument(debug_span!("captive-portal")),
+ );
+ match captive_portal_check.await {
+ Ok(Ok(found)) => Some(found),
+ Ok(Err(err)) => {
+ let err: Result<reqwest::Error, _> = err.downcast();
+ match err {
+ Ok(req_err) if req_err.is_connect() => {
+ debug!("check_captive_portal failed: {req_err:#}");
}
- None
- }
- Err(_) => {
- warn!("check_captive_portal timed out");
- None
- }
- }
- })),
- };
+ Ok(req_err) => warn!("check_captive_portal error: {req_err:#}"),
+ Err(any_err) => warn!("check_captive_portal error: {any_err:#}"),
+ }
+ None
+ }
+ Err(_) => {
+ warn!("check_captive_portal timed out");
+ None
+ }
+ }
+ }));
}
self.outstanding_tasks.captive_task = false;
- MaybeFuture::default()
+ captive_task
}
/// Prepares the future which will run all the probes as per generated ProbePlan.
@@ -2302,16 +2338,16 @@
let plan = match self.last_report {
Some(ref report) => ProbePlan::with_last_report(
&self.relay_map,
- #[cfg(not(wasm_browser))]
- &if_state,
report,
&self.protocols,
+ #[cfg(not(wasm_browser))]
+ &if_state,
),
None => ProbePlan::initial(
&self.relay_map,
+ &self.protocols,
#[cfg(not(wasm_browser))]
&if_state,
- &self.protocols,
),
};
trace!(%plan, "probe plan");
@@ -2886,6 +2922,7 @@
/// Do a staggared ipv4 DNS lookup based on [`RelayNode`]
///
/// `port` is combined with the resolved [`std::net::Ipv4Addr`] to return a [`SocketAddr`]
+#[cfg(not(wasm_browser))]
async fn relay_lookup_ipv4_staggered(
dns_resolver: &DnsResolver,
relay: &RelayNode,
@@ -2915,6 +2952,7 @@
/// Do a staggared ipv6 DNS lookup based on [`RelayNode`]
///
/// `port` is combined with the resolved [`std::net::Ipv6Addr`] to return a [`SocketAddr`]
+#[cfg(not(wasm_browser))]
async fn relay_lookup_ipv6_staggered(
dns_resolver: &DnsResolver,
relay: &RelayNode,
diff --git a/pr/3139/docs/src/iroh_net_report/reportgen/probes.rs.html b/pr/3139/docs/src/iroh_net_report/reportgen/probes.rs.html
index 6029549d56..e08788d3ab 100644
--- a/pr/3139/docs/src/iroh_net_report/reportgen/probes.rs.html
+++ b/pr/3139/docs/src/iroh_net_report/reportgen/probes.rs.html
@@ -1177,22 +1177,7 @@
1176
1177
1178
-1179
-1180
-1181
-1182
-1183
-1184
-1185
-1186
-1187
-1188
-1189
-1190
-1191
-1192
-1193
-1194
//! The relay probes.
+1179
//! The relay probes.
//!
//! All the probes try and establish the latency to the relay servers. Preferably the STUN
//! probes work and we also learn about our public IP addresses and ports. But fallback
@@ -1443,8 +1428,8 @@
#[cfg(not(wasm_browser))]
pub(super) fn initial(
relay_map: &RelayMap,
- if_state: &interfaces::State,
protocols: &BTreeSet<ProbeProto>,
+ if_state: &interfaces::State,
) -> Self {
let mut plan = Self {
set: BTreeSet::new(),
@@ -1543,7 +1528,9 @@
plan
}
- /// Creates an initial probe plan.
+ /// Creates an initial probe plan for browsers.
+ ///
+ /// Here, we essentially only run HTTPS probes without any delays waiting for STUN.
#[cfg(wasm_browser)]
pub(super) fn initial(relay_map: &RelayMap, protocols: &BTreeSet<ProbeProto>) -> Self {
let mut plan = Self {
@@ -1551,22 +1538,11 @@
protocols: protocols.clone(),
};
- // The first time we need add probes after the STUN we record this delay, so that
- // further relay server can reuse this delay.
- let mut max_high_prio_delay: Option<Duration> = None;
-
for relay_node in relay_map.nodes() {
let mut https_probes = ProbeSet::new(ProbeProto::Https);
- for attempt in 0..3 {
- let mut start = *max_high_prio_delay.get_or_insert_with(|| plan.max_delay());
- // if there are high priority probes, ensure there is a buffer between
- // the highest probe delay and the next probes we create
- // if there are no high priority probes, we don't need a buffer
- if plan.has_priority_probes() {
- start += DEFAULT_INITIAL_RETRANSMIT;
- }
- let delay = start + DEFAULT_INITIAL_RETRANSMIT * attempt as u32;
+ for attempt in 0u32..3 {
+ let delay = DEFAULT_INITIAL_RETRANSMIT * attempt;
https_probes
.push(Probe::Https {
delay,
@@ -1580,16 +1556,18 @@
plan
}
- /// Creates a follow up probe plan using a previous net_report report.
+ /// Creates a follow up probe plan using a previous net_report report in browsers.
+ ///
+ /// This will only schedule HTTPS probes.
#[cfg(not(wasm_browser))]
pub(super) fn with_last_report(
relay_map: &RelayMap,
- if_state: &interfaces::State,
last_report: &Report,
protocols: &BTreeSet<ProbeProto>,
+ if_state: &interfaces::State,
) -> Self {
if last_report.relay_latency.is_empty() {
- return Self::initial(relay_map, if_state, protocols);
+ return Self::initial(relay_map, protocols, if_state);
}
let mut plan = Self {
set: Default::default(),
@@ -1737,22 +1715,16 @@
protocols: protocols.clone(),
};
- // The first time we need add probes after the STUN we record this delay, so that
- // further relay servers can reuse this delay.
- let mut max_stun_delay: Option<Duration> = None;
-
let sorted_relays = sort_relays(relay_map, last_report);
for (ri, (url, relay_node)) in sorted_relays.into_iter().enumerate() {
if ri == NUM_INCREMENTAL_RELAYS {
break;
}
- // By default, each node only gets one STUN packet sent,
- // except the fastest two from the previous round.
- let mut attempts = 1;
- let is_fastest_two = ri < 2;
-
- if is_fastest_two {
+ // By default, each node only gets one probe sent,
+ let mut attempts: u32 = 1;
+ // except the fastest two from the previous round.
+ if ri < 2 {
attempts = 2;
}
if Some(url) == last_report.preferred_relay.as_ref() {
@@ -1767,11 +1739,9 @@
.unwrap_or(DEFAULT_ACTIVE_RETRANSMIT_DELAY);
let mut https_probes = ProbeSet::new(ProbeProto::Https);
- let start = *max_stun_delay.get_or_insert_with(|| plan.max_delay());
for attempt in 0..attempts {
- let delay = start
- + (retransmit_delay * attempt as u32)
- + (ACTIVE_RETRANSMIT_EXTRA_DELAY * (attempt as u32 + 1));
+ let delay =
+ (retransmit_delay * attempt) + (ACTIVE_RETRANSMIT_EXTRA_DELAY * (attempt + 1));
https_probes
.push(Probe::Https {
delay,
@@ -1930,7 +1900,7 @@
let relay_node_1 = relay_map.nodes().next().unwrap();
let relay_node_2 = relay_map.nodes().nth(1).unwrap();
let if_state = interfaces::State::fake();
- let plan = ProbePlan::initial(&relay_map, &if_state, &default_protocols());
+ let plan = ProbePlan::initial(&relay_map, &default_protocols(), &if_state);
let mut expected_plan: ProbePlan = [
probeset! {
@@ -2054,8 +2024,8 @@
let if_state = interfaces::State::fake();
let plan = ProbePlan::initial(
&relay_map,
- &if_state,
&BTreeSet::from([ProbeProto::Https, ProbeProto::IcmpV4, ProbeProto::IcmpV6]),
+ &if_state,
);
let mut expected_plan: ProbePlan = [
@@ -2153,9 +2123,9 @@
};
let plan = ProbePlan::with_last_report(
&relay_map,
- &if_state,
&last_report,
&default_protocols(),
+ &if_state,
);
let mut expected_plan: ProbePlan = [
probeset! {