Skip to content

Commit fa53600

Browse files
committed
PR review feedback:
- rename :net_report::Config to Nnet_report::NetReportConfig - better documentation of net report config options
1 parent 2b94917 commit fa53600

5 files changed

Lines changed: 37 additions & 24 deletions

File tree

iroh/src/endpoint.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub use self::{
101101
#[cfg(not(wasm_browser))]
102102
use crate::socket::transports::IpConfig;
103103
use crate::socket::transports::TransportConfig;
104-
pub use crate::{net_report::Config as NetReportConfig, portmapper::PortmapperConfig};
104+
pub use crate::{net_report::NetReportConfig, portmapper::PortmapperConfig};
105105

106106
/// Builder for [`Endpoint`].
107107
///
@@ -706,10 +706,13 @@ impl Builder {
706706
self
707707
}
708708

709-
/// Configures the net report service.
709+
/// Configures the net report.
710710
///
711-
/// Controls which probes (HTTPS latency, captive portal detection) are run.
712-
/// Defaults to all probes enabled.
711+
/// The net report component is responsible for figuring out if and how the endpoint is connected to the internet.
712+
/// It does this by doing various probes to the configured relay servers to get public addresses, NAT behaviour, and
713+
/// relay latencies. In addition it tries to detect captive portals.
714+
///
715+
/// Some non-essential features of the net report component can be disabled via this configuration.
713716
pub fn net_report_config(mut self, config: NetReportConfig) -> Self {
714717
self.net_report_config = config;
715718
self

iroh/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ pub use iroh_base::{
276276
pub use iroh_relay::dns;
277277
pub use iroh_relay::{RelayConfig, RelayMap, endpoint_info};
278278
pub use n0_watcher::Watcher;
279-
pub use net_report::{
280-
Config as NetReportConfig, Report as NetReport, TIMEOUT as NET_REPORT_TIMEOUT,
281-
};
279+
pub use net_report::{NetReportConfig, Report as NetReport, TIMEOUT as NET_REPORT_TIMEOUT};
282280

283281
#[cfg(any(test, feature = "test-utils"))]
284282
pub mod test_utils;

iroh/src/net_report.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,38 @@ pub use self::{
8585
};
8686
pub(crate) use self::{options::Options, reportgen::QuicConfig};
8787

88-
/// Configuration for the net report service.
88+
/// Configuration for the net report component.
8989
///
9090
/// Controls which probes and checks are performed when generating network reports.
9191
/// All options default to `true`.
9292
#[derive(Debug, Clone)]
9393
#[non_exhaustive]
94-
pub struct Config {
94+
pub struct NetReportConfig {
9595
/// Run HTTPS latency probes against relay servers.
9696
///
97-
/// Disable this on constrained devices where the extra TCP connections are
98-
/// too expensive — QAD (UDP) probes already measure relay latency.
97+
/// HTTPS latency probes perform an empty HTTPS GET request to each configured
98+
/// relay server and measure latency.
99+
///
100+
/// They are performed in addition to the QUIC address discovery (QAD) probes.
101+
/// They are the only way to detect relay latencies and thus the preferred relay
102+
/// in networks that do not allow QUIC traffic.
103+
///
104+
/// Disabling them is harmless on networks that do allow QUIC traffic, but will
105+
/// completely prevent finding the home relay on networks that do block QUIC.
99106
pub https_probes: bool,
107+
100108
/// Check for captive portals when generating the first report.
101109
///
102-
/// Disable this on embedded devices or environments where captive portal
103-
/// detection is not meaningful.
110+
/// This is done by accessing a well-known URL that is available on each relay
111+
/// server, `/generate_204`. If a GET request to this URL returns anything else
112+
/// but a 204 No Content response, we assume we are behind a captive portal.
113+
///
114+
/// When we have detected that we are behind a captive portal, we try to contact
115+
/// the relay servers more frequently in case the captive portal status changes.
104116
pub captive_portal_check: bool,
105117
}
106118

107-
impl Config {
119+
impl NetReportConfig {
108120
/// Creates a minimal configuration that disables all optional probes and checks.
109121
pub fn minimal() -> Self {
110122
Self {
@@ -114,7 +126,7 @@ impl Config {
114126
}
115127
}
116128

117-
impl Default for Config {
129+
impl Default for NetReportConfig {
118130
fn default() -> Self {
119131
Self {
120132
https_probes: true,

iroh/src/net_report/options.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) use imp::Options;
66
mod imp {
77
use std::collections::BTreeSet;
88

9-
use crate::net_report::{Config, QuicConfig, probes::Probe};
9+
use crate::net_report::{NetReportConfig, QuicConfig, probes::Probe};
1010

1111
/// Options for running probes
1212
///
@@ -22,15 +22,15 @@ mod imp {
2222
/// TLS config for HTTPS probes.
2323
pub(crate) tls_config: rustls::ClientConfig,
2424
/// User-facing configuration.
25-
pub(crate) user_config: Config,
25+
pub(crate) user_config: NetReportConfig,
2626
}
2727

2828
impl Options {
2929
pub(crate) fn new(tls_config: rustls::ClientConfig) -> Self {
3030
Self {
3131
quic_config: None,
3232
tls_config,
33-
user_config: Config::default(),
33+
user_config: NetReportConfig::default(),
3434
}
3535
}
3636
/// Enable quic probes
@@ -40,7 +40,7 @@ mod imp {
4040
}
4141

4242
/// Set the net report configuration.
43-
pub(crate) fn net_report_config(mut self, config: Config) -> Self {
43+
pub(crate) fn net_report_config(mut self, config: NetReportConfig) -> Self {
4444
self.user_config = config;
4545
self
4646
}
@@ -68,7 +68,7 @@ mod imp {
6868
mod imp {
6969
use std::collections::BTreeSet;
7070

71-
use crate::net_report::{Config, Probe};
71+
use crate::net_report::{NetReportConfig, Probe};
7272

7373
/// Options for running probes (in browsers).
7474
///
@@ -77,20 +77,20 @@ mod imp {
7777
#[derive(Debug, Clone)]
7878
pub(crate) struct Options {
7979
/// User-facing configuration.
80-
pub(crate) user_config: Config,
80+
pub(crate) user_config: NetReportConfig,
8181
}
8282

8383
impl Default for Options {
8484
fn default() -> Self {
8585
Self {
86-
user_config: Config::default(),
86+
user_config: NetReportConfig::default(),
8787
}
8888
}
8989
}
9090

9191
impl Options {
9292
/// Set the net report configuration.
93-
pub(crate) fn net_report_config(mut self, config: Config) -> Self {
93+
pub(crate) fn net_report_config(mut self, config: NetReportConfig) -> Self {
9494
self.user_config = config;
9595
self
9696
}

iroh/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub(crate) struct Options {
150150
pub(crate) hooks: EndpointHooksList,
151151
pub(crate) transport_bias: TransportBiasMap,
152152
pub(crate) portmapper_config: portmapper::PortmapperConfig,
153-
pub(crate) net_report_config: crate::net_report::Config,
153+
pub(crate) net_report_config: crate::net_report::NetReportConfig,
154154

155155
/// Static configuration for the endpoint.
156156
pub(crate) static_config: StaticConfig,

0 commit comments

Comments
 (0)