iroh/net_report/defaults.rs
1//! Default values used in net_report.
2
3/// Contains all timeouts that we use in `iroh-net-report`.
4pub(crate) mod timeouts {
5 use n0_future::time::Duration;
6
7 // Timeouts for net_report
8
9 /// The maximum amount of time, in seconds, the net_report will spend gathering a single report.
10 // This is separated from `OVERALL_REPORT_TIMEOUT` to use as a reference
11 // in documentation outside of this crate. `OVERALL_REPORT_TIMEOUT` is a
12 // duration and rustdoc cannot calculate it at runtime, and so cannot be
13 // used directly for documentation purposes.
14 pub const TIMEOUT: u64 = 5;
15
16 /// The maximum amount of time net_report will spend gathering a single report.
17 pub(crate) const OVERALL_REPORT_TIMEOUT: Duration = Duration::from_secs(TIMEOUT);
18
19 /// The total time we wait for all the probes.
20 ///
21 /// This includes the QAD and HTTPS probes, which will all
22 /// start at different times based on the ProbePlan.
23 pub(crate) const PROBES_TIMEOUT: Duration = Duration::from_secs(3);
24
25 /// How long to await for a captive-portal result.
26 ///
27 /// This delay is chosen so it starts after good-working QAD probes
28 /// would have finished, but not too long so the delay is bearable if
29 /// UDP/QAD is blocked.
30 pub(crate) const CAPTIVE_PORTAL_DELAY: Duration = Duration::from_millis(200);
31
32 /// Timeout for captive portal checks
33 ///
34 /// Must be lower than [`OVERALL_REPORT_TIMEOUT`] minus
35 /// [`CAPTIVE_PORTAL_DELAY`].
36 pub(crate) const CAPTIVE_PORTAL_TIMEOUT: Duration = Duration::from_secs(2);
37
38 pub(crate) const DNS_TIMEOUT: Duration = Duration::from_secs(3);
39}