deploy: c455b3f5153bc1114e41b7c8a5bdee82eaef49fd

This commit is contained in:
matheus23
2025-02-12 10:57:14 +00:00
parent 7f0af34eea
commit 170999b02b
12 changed files with 171 additions and 123 deletions
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Attempts to bind a local socket to send STUN packets from."><title>bind_local_stun_socket in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">bind_local_stun_socket</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#945-989">Source</a> </span></div><pre class="rust item-decl"><code>pub fn bind_local_stun_socket(
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Attempts to bind a local socket to send STUN packets from."><title>bind_local_stun_socket in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">bind_local_stun_socket</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#965-1009">Source</a> </span></div><pre class="rust item-decl"><code>pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: <a class="struct" href="struct.Addr.html" title="struct iroh_net_report::Addr">Addr</a>,
cancel_token: CancellationToken,
@@ -1,2 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Test if IPv6 works at all, or if it’s been hard disabled at the OS level."><title>os_has_ipv6 in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">os_has_ipv6</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#928-930">Source</a> </span></div><pre class="rust item-decl"><code>pub fn os_has_ipv6() -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Test if IPv6 works at all, or if it’s been hard disabled at the OS level."><title>os_has_ipv6 in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">os_has_ipv6</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#948-950">Source</a> </span></div><pre class="rust item-decl"><code>pub fn os_has_ipv6() -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</p>
</div></details></section></div></main></body></html>
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Checks the network conditions from the current host."><title>iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#constants" title="Constants">Constants</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_net_report</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#1-1526">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks the network conditions from the current host.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Checks the network conditions from the current host."><title>iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.32.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#constants" title="Constants">Constants</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_net_report</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#1-1546">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks the network conditions from the current host.</p>
<p>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.</p>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+43 -3
View File
@@ -1524,7 +1524,27 @@
<a href="#1523" id="1523">1523</a>
<a href="#1524" id="1524">1524</a>
<a href="#1525" id="1525">1525</a>
<a href="#1526" id="1526">1526</a></pre></div><pre class="rust"><code><span class="doccomment">//! Checks the network conditions from the current host.
<a href="#1526" id="1526">1526</a>
<a href="#1527" id="1527">1527</a>
<a href="#1528" id="1528">1528</a>
<a href="#1529" id="1529">1529</a>
<a href="#1530" id="1530">1530</a>
<a href="#1531" id="1531">1531</a>
<a href="#1532" id="1532">1532</a>
<a href="#1533" id="1533">1533</a>
<a href="#1534" id="1534">1534</a>
<a href="#1535" id="1535">1535</a>
<a href="#1536" id="1536">1536</a>
<a href="#1537" id="1537">1537</a>
<a href="#1538" id="1538">1538</a>
<a href="#1539" id="1539">1539</a>
<a href="#1540" id="1540">1540</a>
<a href="#1541" id="1541">1541</a>
<a href="#1542" id="1542">1542</a>
<a href="#1543" id="1543">1543</a>
<a href="#1544" id="1544">1544</a>
<a href="#1545" id="1545">1545</a>
<a href="#1546" id="1546">1546</a></pre></div><pre class="rust"><code><span class="doccomment">//! 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 @@
</span><span class="kw">mod </span>ping;
<span class="kw">mod </span>reportgen;
<span class="doccomment">/// 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.
</span><span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub mod </span>portmapper {
<span class="doccomment">/// Output of a port mapping probe.
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
#[display(<span class="string">"portmap={{ UPnP: {upnp}, PMP: {nat_pmp}, PCP: {pcp} }}"</span>)]
</span><span class="kw">pub struct </span>ProbeOutput {
<span class="doccomment">/// If UPnP can be considered available.
</span><span class="kw">pub </span>upnp: bool,
<span class="doccomment">/// If PCP can be considered available.
</span><span class="kw">pub </span>pcp: bool,
<span class="doccomment">/// If PMP can be considered available.
</span><span class="kw">pub </span>nat_pmp: bool,
}
}
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub use </span>ip_mapped_addrs::{IpMappedAddr, IpMappedAddrError, IpMappedAddresses, MAPPED_ADDR_PORT};
<span class="kw">pub use </span>metrics::Metrics;
<span class="kw">use </span>reportgen::ProbeProto;
<span class="kw">pub use </span>reportgen::QuicConfig;
<span class="kw">use </span>reportgen::{ProbeProto, SocketState};
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">use </span>reportgen::SocketState;
<span class="attr">#[cfg(feature = <span class="string">"stun-utils"</span>)]
</span><span class="kw">pub use </span>stun_utils::bind_local_stun_socket;
@@ -1620,7 +1661,6 @@
/// public IP address (on IPv4).
</span><span class="kw">pub </span>hair_pinning: <span class="prelude-ty">Option</span>&lt;bool&gt;,
<span class="doccomment">/// Probe indicating the presence of port mapping protocols on the LAN.
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub </span>portmap_probe: <span class="prelude-ty">Option</span>&lt;portmapper::ProbeOutput&gt;,
<span class="doccomment">/// `None` for unknown
</span><span class="kw">pub </span>preferred_relay: <span class="prelude-ty">Option</span>&lt;RelayUrl&gt;,
@@ -1736,7 +1736,26 @@
<a href="#1735" id="1735">1735</a>
<a href="#1736" id="1736">1736</a>
<a href="#1737" id="1737">1737</a>
<a href="#1738" id="1738">1738</a></pre></div><pre class="rust"><code><span class="doccomment">//! The reportgen actor is responsible for generating a single net_report report.
<a href="#1738" id="1738">1738</a>
<a href="#1739" id="1739">1739</a>
<a href="#1740" id="1740">1740</a>
<a href="#1741" id="1741">1741</a>
<a href="#1742" id="1742">1742</a>
<a href="#1743" id="1743">1743</a>
<a href="#1744" id="1744">1744</a>
<a href="#1745" id="1745">1745</a>
<a href="#1746" id="1746">1746</a>
<a href="#1747" id="1747">1747</a>
<a href="#1748" id="1748">1748</a>
<a href="#1749" id="1749">1749</a>
<a href="#1750" id="1750">1750</a>
<a href="#1751" id="1751">1751</a>
<a href="#1752" id="1752">1752</a>
<a href="#1753" id="1753">1753</a>
<a href="#1754" id="1754">1754</a>
<a href="#1755" id="1755">1755</a>
<a href="#1756" id="1756">1756</a>
<a href="#1757" id="1757">1757</a></pre></div><pre class="rust"><code><span class="doccomment">//! 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,
};
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">use </span>n0_future::future::Pending;
<span class="kw">use </span>n0_future::{
task::{<span class="self">self</span>, AbortOnDropHandle, JoinSet},
time::{<span class="self">self</span>, Duration, Instant},
@@ -1787,7 +1808,9 @@
<span class="kw">use </span>tracing::{debug, debug_span, error, info_span, trace, warn, Instrument, Span};
<span class="kw">use </span>url::Host;
<span class="attr">#[cfg(feature = <span class="string">"metrics"</span>)]
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">use </span><span class="kw">crate</span>::portmapper; <span class="comment">// We stub the library
</span><span class="attr">#[cfg(feature = <span class="string">"metrics"</span>)]
</span><span class="kw">use </span><span class="kw">crate</span>::Metrics;
<span class="kw">use crate</span>::{<span class="self">self </span><span class="kw">as </span>net_report, Report};
<span class="attr">#[cfg(not(wasm_browser))]
@@ -1820,8 +1843,9 @@
</span>_drop_guard: AbortOnDropHandle&lt;()&gt;,
}
<span class="attr">#[derive(Debug, Clone)]
</span><span class="kw">pub struct </span>SocketState {
<span class="attr">#[cfg(not(wasm_browser))]
#[derive(Debug, Clone)]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">struct </span>SocketState {
<span class="doccomment">/// The portmapper client, if there is one.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) port_mapper: <span class="prelude-ty">Option</span>&lt;portmapper::Client&gt;,
<span class="doccomment">/// Socket to send IPv4 STUN requests from.
@@ -2201,7 +2225,14 @@
</span><span class="kw">fn </span>prepare_portmapper_task(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
) -&gt; MaybeFuture&lt;Pin&lt;Box&lt;<span class="kw">impl </span>Future&lt;Output = <span class="prelude-ty">Option</span>&lt;portmapper::ProbeOutput&gt;&gt;&gt;&gt;&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>port_mapping = MaybeFuture::default();
<span class="comment">// In the browser, the compiler struggles to infer the type of future inside, because it's never set.
</span><span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>port_mapping: MaybeFuture&lt;Pin&lt;Box&lt;Pending&lt;<span class="prelude-ty">Option</span>&lt;portmapper::ProbeOutput&gt;&gt;&gt;&gt;&gt; =
MaybeFuture::default();
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span><span class="kw-2">mut </span>port_mapping = MaybeFuture::default();
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(port_mapper) = <span class="self">self</span>.socket_state.port_mapper.clone() {
port_mapping.inner = <span class="prelude-val">Some</span>(Box::pin(<span class="kw">async move </span>{
@@ -2226,6 +2257,13 @@
</span><span class="kw">fn </span>prepare_captive_portal_task(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
) -&gt; MaybeFuture&lt;Pin&lt;Box&lt;<span class="kw">impl </span>Future&lt;Output = <span class="prelude-ty">Option</span>&lt;bool&gt;&gt;&gt;&gt;&gt; {
<span class="comment">// In the browser case the compiler cannot infer the type of the future, because it's never set:
</span><span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>captive_task: MaybeFuture&lt;Pin&lt;Box&lt;Pending&lt;<span class="prelude-ty">Option</span>&lt;bool&gt;&gt;&gt;&gt;&gt; = MaybeFuture::default();
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span><span class="kw-2">mut </span>captive_task = MaybeFuture::default();
<span class="comment">// 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 @@
<span class="kw">let </span>dns_resolver = <span class="self">self</span>.socket_state.dns_resolver.clone();
<span class="kw">let </span>dm = <span class="self">self</span>.relay_map.clone();
<span class="self">self</span>.outstanding_tasks.captive_task = <span class="bool-val">true</span>;
<span class="kw">return </span>MaybeFuture {
inner: <span class="prelude-val">Some</span>(Box::pin(<span class="kw">async move </span>{
time::sleep(CAPTIVE_PORTAL_DELAY).<span class="kw">await</span>;
<span class="macro">debug!</span>(<span class="string">"Captive portal check started after {CAPTIVE_PORTAL_DELAY:?}"</span>);
<span class="kw">let </span>captive_portal_check = time::timeout(
CAPTIVE_PORTAL_TIMEOUT,
check_captive_portal(<span class="kw-2">&amp;</span>dns_resolver, <span class="kw-2">&amp;</span>dm, preferred_relay)
.instrument(<span class="macro">debug_span!</span>(<span class="string">"captive-portal"</span>)),
);
<span class="kw">match </span>captive_portal_check.<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(<span class="prelude-val">Ok</span>(found)) =&gt; <span class="prelude-val">Some</span>(found),
<span class="prelude-val">Ok</span>(<span class="prelude-val">Err</span>(err)) =&gt; {
<span class="kw">let </span>err: <span class="prelude-ty">Result</span>&lt;reqwest::Error, <span class="kw">_</span>&gt; = err.downcast();
<span class="kw">match </span>err {
<span class="prelude-val">Ok</span>(req_err) <span class="kw">if </span>req_err.is_connect() =&gt; {
<span class="macro">debug!</span>(<span class="string">"check_captive_portal failed: {req_err:#}"</span>);
}
<span class="prelude-val">Ok</span>(req_err) =&gt; <span class="macro">warn!</span>(<span class="string">"check_captive_portal error: {req_err:#}"</span>),
<span class="prelude-val">Err</span>(any_err) =&gt; <span class="macro">warn!</span>(<span class="string">"check_captive_portal error: {any_err:#}"</span>),
captive_task.inner = <span class="prelude-val">Some</span>(Box::pin(<span class="kw">async move </span>{
time::sleep(CAPTIVE_PORTAL_DELAY).<span class="kw">await</span>;
<span class="macro">debug!</span>(<span class="string">"Captive portal check started after {CAPTIVE_PORTAL_DELAY:?}"</span>);
<span class="kw">let </span>captive_portal_check = time::timeout(
CAPTIVE_PORTAL_TIMEOUT,
check_captive_portal(<span class="kw-2">&amp;</span>dns_resolver, <span class="kw-2">&amp;</span>dm, preferred_relay)
.instrument(<span class="macro">debug_span!</span>(<span class="string">"captive-portal"</span>)),
);
<span class="kw">match </span>captive_portal_check.<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(<span class="prelude-val">Ok</span>(found)) =&gt; <span class="prelude-val">Some</span>(found),
<span class="prelude-val">Ok</span>(<span class="prelude-val">Err</span>(err)) =&gt; {
<span class="kw">let </span>err: <span class="prelude-ty">Result</span>&lt;reqwest::Error, <span class="kw">_</span>&gt; = err.downcast();
<span class="kw">match </span>err {
<span class="prelude-val">Ok</span>(req_err) <span class="kw">if </span>req_err.is_connect() =&gt; {
<span class="macro">debug!</span>(<span class="string">"check_captive_portal failed: {req_err:#}"</span>);
}
<span class="prelude-val">None
</span>}
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; {
<span class="macro">warn!</span>(<span class="string">"check_captive_portal timed out"</span>);
<span class="prelude-val">None
</span>}
}
})),
};
<span class="prelude-val">Ok</span>(req_err) =&gt; <span class="macro">warn!</span>(<span class="string">"check_captive_portal error: {req_err:#}"</span>),
<span class="prelude-val">Err</span>(any_err) =&gt; <span class="macro">warn!</span>(<span class="string">"check_captive_portal error: {any_err:#}"</span>),
}
<span class="prelude-val">None
</span>}
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; {
<span class="macro">warn!</span>(<span class="string">"check_captive_portal timed out"</span>);
<span class="prelude-val">None
</span>}
}
}));
}
<span class="self">self</span>.outstanding_tasks.captive_task = <span class="bool-val">false</span>;
MaybeFuture::default()
captive_task
}
<span class="doccomment">/// Prepares the future which will run all the probes as per generated ProbePlan.
@@ -2302,16 +2338,16 @@
<span class="kw">let </span>plan = <span class="kw">match </span><span class="self">self</span>.last_report {
<span class="prelude-val">Some</span>(<span class="kw-2">ref </span>report) =&gt; ProbePlan::with_last_report(
<span class="kw-2">&amp;</span><span class="self">self</span>.relay_map,
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw-2">&amp;</span>if_state,
report,
<span class="kw-2">&amp;</span><span class="self">self</span>.protocols,
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw-2">&amp;</span>if_state,
),
<span class="prelude-val">None </span>=&gt; ProbePlan::initial(
<span class="kw-2">&amp;</span><span class="self">self</span>.relay_map,
<span class="kw-2">&amp;</span><span class="self">self</span>.protocols,
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw-2">&amp;</span>if_state,
<span class="kw-2">&amp;</span><span class="self">self</span>.protocols,
),
};
<span class="macro">trace!</span>(%plan, <span class="string">"probe plan"</span>);
@@ -2886,6 +2922,7 @@
<span class="doccomment">/// Do a staggared ipv4 DNS lookup based on [`RelayNode`]
///
/// `port` is combined with the resolved [`std::net::Ipv4Addr`] to return a [`SocketAddr`]
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">async fn </span>relay_lookup_ipv4_staggered(
dns_resolver: <span class="kw-2">&amp;</span>DnsResolver,
relay: <span class="kw-2">&amp;</span>RelayNode,
@@ -2915,6 +2952,7 @@
<span class="doccomment">/// Do a staggared ipv6 DNS lookup based on [`RelayNode`]
///
/// `port` is combined with the resolved [`std::net::Ipv6Addr`] to return a [`SocketAddr`]
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">async fn </span>relay_lookup_ipv6_staggered(
dns_resolver: <span class="kw-2">&amp;</span>DnsResolver,
relay: <span class="kw-2">&amp;</span>RelayNode,
@@ -1177,22 +1177,7 @@
<a href="#1176" id="1176">1176</a>
<a href="#1177" id="1177">1177</a>
<a href="#1178" id="1178">1178</a>
<a href="#1179" id="1179">1179</a>
<a href="#1180" id="1180">1180</a>
<a href="#1181" id="1181">1181</a>
<a href="#1182" id="1182">1182</a>
<a href="#1183" id="1183">1183</a>
<a href="#1184" id="1184">1184</a>
<a href="#1185" id="1185">1185</a>
<a href="#1186" id="1186">1186</a>
<a href="#1187" id="1187">1187</a>
<a href="#1188" id="1188">1188</a>
<a href="#1189" id="1189">1189</a>
<a href="#1190" id="1190">1190</a>
<a href="#1191" id="1191">1191</a>
<a href="#1192" id="1192">1192</a>
<a href="#1193" id="1193">1193</a>
<a href="#1194" id="1194">1194</a></pre></div><pre class="rust"><code><span class="doccomment">//! The relay probes.
<a href="#1179" id="1179">1179</a></pre></div><pre class="rust"><code><span class="doccomment">//! 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 @@
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">fn </span>initial(
relay_map: <span class="kw-2">&amp;</span>RelayMap,
if_state: <span class="kw-2">&amp;</span>interfaces::State,
protocols: <span class="kw-2">&amp;</span>BTreeSet&lt;ProbeProto&gt;,
if_state: <span class="kw-2">&amp;</span>interfaces::State,
) -&gt; <span class="self">Self </span>{
<span class="kw">let </span><span class="kw-2">mut </span>plan = <span class="self">Self </span>{
set: BTreeSet::new(),
@@ -1543,7 +1528,9 @@
plan
}
<span class="doccomment">/// Creates an initial probe plan.
<span class="doccomment">/// Creates an initial probe plan for browsers.
///
/// Here, we essentially only run HTTPS probes without any delays waiting for STUN.
</span><span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">fn </span>initial(relay_map: <span class="kw-2">&amp;</span>RelayMap, protocols: <span class="kw-2">&amp;</span>BTreeSet&lt;ProbeProto&gt;) -&gt; <span class="self">Self </span>{
<span class="kw">let </span><span class="kw-2">mut </span>plan = <span class="self">Self </span>{
@@ -1551,22 +1538,11 @@
protocols: protocols.clone(),
};
<span class="comment">// The first time we need add probes after the STUN we record this delay, so that
// further relay server can reuse this delay.
</span><span class="kw">let </span><span class="kw-2">mut </span>max_high_prio_delay: <span class="prelude-ty">Option</span>&lt;Duration&gt; = <span class="prelude-val">None</span>;
<span class="kw">for </span>relay_node <span class="kw">in </span>relay_map.nodes() {
<span class="kw">let </span><span class="kw-2">mut </span>https_probes = ProbeSet::new(ProbeProto::Https);
<span class="kw">for </span>attempt <span class="kw">in </span><span class="number">0</span>..<span class="number">3 </span>{
<span class="kw">let </span><span class="kw-2">mut </span>start = <span class="kw-2">*</span>max_high_prio_delay.get_or_insert_with(|| plan.max_delay());
<span class="comment">// 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
</span><span class="kw">if </span>plan.has_priority_probes() {
start += DEFAULT_INITIAL_RETRANSMIT;
}
<span class="kw">let </span>delay = start + DEFAULT_INITIAL_RETRANSMIT * attempt <span class="kw">as </span>u32;
<span class="kw">for </span>attempt <span class="kw">in </span><span class="number">0u32</span>..<span class="number">3 </span>{
<span class="kw">let </span>delay = DEFAULT_INITIAL_RETRANSMIT * attempt;
https_probes
.push(Probe::Https {
delay,
@@ -1580,16 +1556,18 @@
plan
}
<span class="doccomment">/// Creates a follow up probe plan using a previous net_report report.
<span class="doccomment">/// Creates a follow up probe plan using a previous net_report report in browsers.
///
/// This will only schedule HTTPS probes.
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">fn </span>with_last_report(
relay_map: <span class="kw-2">&amp;</span>RelayMap,
if_state: <span class="kw-2">&amp;</span>interfaces::State,
last_report: <span class="kw-2">&amp;</span>Report,
protocols: <span class="kw-2">&amp;</span>BTreeSet&lt;ProbeProto&gt;,
if_state: <span class="kw-2">&amp;</span>interfaces::State,
) -&gt; <span class="self">Self </span>{
<span class="kw">if </span>last_report.relay_latency.is_empty() {
<span class="kw">return </span><span class="self">Self</span>::initial(relay_map, if_state, protocols);
<span class="kw">return </span><span class="self">Self</span>::initial(relay_map, protocols, if_state);
}
<span class="kw">let </span><span class="kw-2">mut </span>plan = <span class="self">Self </span>{
set: Default::default(),
@@ -1737,22 +1715,16 @@
protocols: protocols.clone(),
};
<span class="comment">// The first time we need add probes after the STUN we record this delay, so that
// further relay servers can reuse this delay.
</span><span class="kw">let </span><span class="kw-2">mut </span>max_stun_delay: <span class="prelude-ty">Option</span>&lt;Duration&gt; = <span class="prelude-val">None</span>;
<span class="kw">let </span>sorted_relays = sort_relays(relay_map, last_report);
<span class="kw">for </span>(ri, (url, relay_node)) <span class="kw">in </span>sorted_relays.into_iter().enumerate() {
<span class="kw">if </span>ri == NUM_INCREMENTAL_RELAYS {
<span class="kw">break</span>;
}
<span class="comment">// By default, each node only gets one STUN packet sent,
// except the fastest two from the previous round.
</span><span class="kw">let </span><span class="kw-2">mut </span>attempts = <span class="number">1</span>;
<span class="kw">let </span>is_fastest_two = ri &lt; <span class="number">2</span>;
<span class="kw">if </span>is_fastest_two {
<span class="comment">// By default, each node only gets one probe sent,
</span><span class="kw">let </span><span class="kw-2">mut </span>attempts: u32 = <span class="number">1</span>;
<span class="comment">// except the fastest two from the previous round.
</span><span class="kw">if </span>ri &lt; <span class="number">2 </span>{
attempts = <span class="number">2</span>;
}
<span class="kw">if </span><span class="prelude-val">Some</span>(url) == last_report.preferred_relay.as_ref() {
@@ -1767,11 +1739,9 @@
</span>.unwrap_or(DEFAULT_ACTIVE_RETRANSMIT_DELAY);
<span class="kw">let </span><span class="kw-2">mut </span>https_probes = ProbeSet::new(ProbeProto::Https);
<span class="kw">let </span>start = <span class="kw-2">*</span>max_stun_delay.get_or_insert_with(|| plan.max_delay());
<span class="kw">for </span>attempt <span class="kw">in </span><span class="number">0</span>..attempts {
<span class="kw">let </span>delay = start
+ (retransmit_delay * attempt <span class="kw">as </span>u32)
+ (ACTIVE_RETRANSMIT_EXTRA_DELAY * (attempt <span class="kw">as </span>u32 + <span class="number">1</span>));
<span class="kw">let </span>delay =
(retransmit_delay * attempt) + (ACTIVE_RETRANSMIT_EXTRA_DELAY * (attempt + <span class="number">1</span>));
https_probes
.push(Probe::Https {
delay,
@@ -1930,7 +1900,7 @@
<span class="kw">let </span>relay_node_1 = relay_map.nodes().next().unwrap();
<span class="kw">let </span>relay_node_2 = relay_map.nodes().nth(<span class="number">1</span>).unwrap();
<span class="kw">let </span>if_state = interfaces::State::fake();
<span class="kw">let </span>plan = ProbePlan::initial(<span class="kw-2">&amp;</span>relay_map, <span class="kw-2">&amp;</span>if_state, <span class="kw-2">&amp;</span>default_protocols());
<span class="kw">let </span>plan = ProbePlan::initial(<span class="kw-2">&amp;</span>relay_map, <span class="kw-2">&amp;</span>default_protocols(), <span class="kw-2">&amp;</span>if_state);
<span class="kw">let </span><span class="kw-2">mut </span>expected_plan: ProbePlan = [
<span class="macro">probeset!</span> {
@@ -2054,8 +2024,8 @@
<span class="kw">let </span>if_state = interfaces::State::fake();
<span class="kw">let </span>plan = ProbePlan::initial(
<span class="kw-2">&amp;</span>relay_map,
<span class="kw-2">&amp;</span>if_state,
<span class="kw-2">&amp;</span>BTreeSet::from([ProbeProto::Https, ProbeProto::IcmpV4, ProbeProto::IcmpV6]),
<span class="kw-2">&amp;</span>if_state,
);
<span class="kw">let </span><span class="kw-2">mut </span>expected_plan: ProbePlan = [
@@ -2153,9 +2123,9 @@
};
<span class="kw">let </span>plan = ProbePlan::with_last_report(
<span class="kw-2">&amp;</span>relay_map,
<span class="kw-2">&amp;</span>if_state,
<span class="kw-2">&amp;</span>last_report,
<span class="kw-2">&amp;</span>default_protocols(),
<span class="kw-2">&amp;</span>if_state,
);
<span class="kw">let </span><span class="kw-2">mut </span>expected_plan: ProbePlan = [
<span class="macro">probeset!</span> {