Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions iroh/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ use crate::discovery::pkarr::PkarrResolver;
#[cfg(not(wasm_browser))]
use crate::dns::DnsResolver;
use crate::{
NetReport,
discovery::{ConcurrentDiscovery, DiscoveryError, DynIntoDiscovery, IntoDiscovery, UserData},
endpoint::presets::Preset,
magicsock::{self, Handle, RemoteStateActorStoppedError, mapped_addrs::MappedAddr},
metrics::EndpointMetrics,
net_report::Report,
tls::{self, DEFAULT_MAX_TLS_TICKETS},
};

Expand Down Expand Up @@ -867,8 +867,8 @@ impl Endpoint {
///
/// This has no timeout, so if that is needed, you need to wrap it in a
/// timeout. We recommend using a timeout close to
/// [`crate::net_report::TIMEOUT`], so you can be sure that at least one
/// [`crate::net_report::Report`] has been attempted.
/// [`crate::NET_REPORT_TIMEOUT`]s, so you can be sure that at least one
/// [`crate::NetReport`] has been attempted.
///
/// To understand if the endpoint has gone back "offline",
/// you must use the [`Endpoint::watch_addr`] method, to
Expand Down Expand Up @@ -906,7 +906,7 @@ impl Endpoint {
/// # });
/// ```
#[doc(hidden)]
pub fn net_report(&self) -> impl Watcher<Value = Option<Report>> + use<> {
pub fn net_report(&self) -> impl Watcher<Value = Option<NetReport>> + use<> {
self.msock.net_report()
}

Expand Down
3 changes: 2 additions & 1 deletion iroh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub mod discovery;
pub mod dns;
pub mod endpoint;
pub mod metrics;
pub mod net_report;
mod net_report;
pub mod protocol;

pub use endpoint::{Endpoint, RelayMode};
Expand All @@ -276,6 +276,7 @@ pub use iroh_base::{
};
pub use iroh_relay::{RelayConfig, RelayMap, endpoint_info};
pub use n0_watcher::Watcher;
pub use net_report::{Report as NetReport, TIMEOUT as NET_REPORT_TIMEOUT};

#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils;
3 changes: 1 addition & 2 deletions iroh/src/net_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,10 @@ enum QadProbeError {
use self::reportgen::SocketState;
pub use self::{
metrics::Metrics,
options::Options,
probes::Probe,
report::{RelayLatencies, Report},
reportgen::QuicConfig,
};
pub(crate) use self::{options::Options, reportgen::QuicConfig};

const FULL_REPORT_INTERVAL: Duration = Duration::from_secs(5 * 60);
const ENOUGH_ENDPOINTS: usize = 3;
Expand Down
32 changes: 8 additions & 24 deletions iroh/src/net_report/options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Options for creating a report gen client.

pub use imp::Options;
pub(crate) use imp::Options;

#[cfg(not(wasm_browser))]
mod imp {
Expand All @@ -14,7 +14,7 @@ mod imp {
///
/// Use [`Options::quic_config`] to enable QUIC address discovery.
#[derive(Debug, Clone)]
pub struct Options {
pub(crate) struct Options {
/// The configuration needed to launch QUIC address discovery probes.
///
/// If not provided, will not run QUIC address discovery.
Expand All @@ -40,37 +40,21 @@ mod imp {
}

impl Options {
/// Create an [`Options`] that disables all probes
pub fn disabled() -> Self {
Self {
quic_config: None,
https: false,
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: false,
}
}

/// Enable quic probes
pub fn quic_config(mut self, quic_config: Option<QuicConfig>) -> Self {
pub(crate) fn quic_config(mut self, quic_config: Option<QuicConfig>) -> Self {
self.quic_config = quic_config;
self
}

/// Enable or disable https probe
pub fn https(mut self, enable: bool) -> Self {
self.https = enable;
self
}

/// Skip cert verification
#[cfg(any(test, feature = "test-utils"))]
pub fn insecure_skip_relay_cert_verify(mut self, skip: bool) -> Self {
pub(crate) fn insecure_skip_relay_cert_verify(mut self, skip: bool) -> Self {
self.insecure_skip_relay_cert_verify = skip;
self
}

/// Turn the options into set of valid protocols
pub fn as_protocols(&self) -> BTreeSet<Probe> {
pub(crate) fn as_protocols(&self) -> BTreeSet<Probe> {
let mut protocols = BTreeSet::new();
if let Some(ref quic) = self.quic_config {
if quic.ipv4 {
Expand Down Expand Up @@ -99,7 +83,7 @@ mod imp {
/// Only HTTPS probes are supported in browsers.
/// These are run by default.
#[derive(Debug, Clone)]
pub struct Options {
pub(crate) struct Options {
/// Enable https probes
///
/// On by default
Expand All @@ -114,12 +98,12 @@ mod imp {

impl Options {
/// Create an [`Options`] that disables all probes
pub fn disabled() -> Self {
pub(crate) fn disabled() -> Self {
Self { https: false }
}

/// Enable or disable https probe
pub fn https(mut self, enable: bool) -> Self {
pub(crate) fn https(mut self, enable: bool) -> Self {
self.https = enable;
self
}
Expand Down
24 changes: 12 additions & 12 deletions iroh/src/net_report/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ pub(super) struct Client {
#[derive(Debug, Clone, Default)]
pub(crate) struct IfStateDetails {
/// Do we have IPv4 capbilities
pub have_v4: bool,
pub(crate) have_v4: bool,
/// Do we have IPv6 capbilities
pub have_v6: bool,
pub(crate) have_v6: bool,
}

impl IfStateDetails {
Expand All @@ -105,11 +105,11 @@ impl From<netwatch::netmon::State> for IfStateDetails {
/// Factored out so it can be disabled easily in browsers.
#[cfg(not(wasm_browser))]
#[derive(Debug, Clone)]
pub(crate) struct SocketState {
pub(super) struct SocketState {
/// QUIC client to do QUIC address Discovery
pub(crate) quic_client: Option<QuicClient>,
pub(super) quic_client: Option<QuicClient>,
/// The DNS resolver to use for probes that need to resolve DNS records.
pub(crate) dns_resolver: DnsResolver,
pub(super) dns_resolver: DnsResolver,
}

impl Client {
Expand Down Expand Up @@ -468,16 +468,16 @@ pub(super) enum QuicError {

/// Pieces needed to do QUIC address discovery.
#[derive(derive_more::Debug, Clone)]
pub struct QuicConfig {
pub(crate) struct QuicConfig {
/// A QUIC Endpoint
#[debug("quinn::Endpoint")]
pub ep: quinn::Endpoint,
pub(crate) ep: quinn::Endpoint,
/// A client config.
pub client_config: rustls::ClientConfig,
pub(crate) client_config: rustls::ClientConfig,
/// Enable ipv4 QUIC address discovery probes
pub ipv4: bool,
pub(crate) ipv4: bool,
/// Enable ipv6 QUIC address discovery probes
pub ipv6: bool,
pub(crate) ipv6: bool,
}

impl Probe {
Expand Down Expand Up @@ -638,7 +638,7 @@ fn get_quic_port(relay: &RelayConfig) -> Option<u16> {
#[cfg(not(wasm_browser))]
#[stack_error(derive, add_meta)]
#[non_exhaustive]
pub enum GetRelayAddrError {
pub(super) enum GetRelayAddrError {
#[error("No valid hostname in the relay URL")]
InvalidHostname,
#[error("No suitable relay address found for {url} ({addr_type})")]
Expand Down Expand Up @@ -758,7 +758,7 @@ async fn relay_lookup_ipv6_staggered(

#[stack_error(derive, add_meta)]
#[non_exhaustive]
pub enum MeasureHttpsLatencyError {
pub(super) enum MeasureHttpsLatencyError {
#[error(transparent)]
InvalidUrl {
#[error(std_err, from)]
Expand Down
Loading