deploy: e3f71a2b8726fe811084af5891c9bbd624eb6015

This commit is contained in:
ramfox
2025-03-05 21:23:25 +00:00
parent 81084a7f37
commit b98a34b04f
14 changed files with 110 additions and 142 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -26,7 +26,7 @@ Note that this <em>overrides</em> the current list of ALPNs.</p>
alpn: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>],
) -&gt; <a class="type" href="https://docs.rs/anyhow/1.0.95/anyhow/type.Result.html" title="type anyhow::Result">Result</a>&lt;<a class="struct" href="struct.Connection.html" title="struct iroh::endpoint::Connection">Connection</a>&gt;</h4></section></summary><div class="docblock"><p>Connects to a remote <a href="struct.Endpoint.html" title="struct iroh::endpoint::Endpoint"><code>Endpoint</code></a>.</p>
<p>A value that can be converted into a <a href="../struct.NodeAddr.html" title="struct iroh::NodeAddr"><code>NodeAddr</code></a> is required. This can be either a
<a href="../struct.NodeAddr.html" title="struct iroh::NodeAddr"><code>NodeAddr</code></a>, a <a href="../type.NodeId.html" title="type iroh::NodeId"><code>NodeId</code></a> or a <a href="../../iroh_base/ticket/node/struct.NodeTicket.html" title="struct iroh_base::ticket::node::NodeTicket"><code>iroh_base::ticket::NodeTicket</code></a>.</p>
<a href="../struct.NodeAddr.html" title="struct iroh::NodeAddr"><code>NodeAddr</code></a>, a <a href="../type.NodeId.html" title="type iroh::NodeId"><code>NodeId</code></a> or a [<code>iroh_base::ticket::NodeTicket</code>].</p>
<p>The <a href="../struct.NodeAddr.html" title="struct iroh::NodeAddr"><code>NodeAddr</code></a> must contain the <a href="../type.NodeId.html" title="type iroh::NodeId"><code>NodeId</code></a> to dial and may also contain a <a href="../struct.RelayUrl.html" title="struct iroh::RelayUrl"><code>RelayUrl</code></a>
and direct addresses. If direct addresses are provided, they will be used to try and
establish a direct connection without involving a relay server.</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
+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="The identifier for a node in the (iroh) network."><title>NodeId in iroh - 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" 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 type"><!--[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/index.html">iroh</a><span class="version">0.33.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">NodeId</a></h2><h3><a href="#aliased-type">Aliased type</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate iroh</a></h2></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</a></span><h1>Type Alias <span class="type">NodeId</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_base/key.rs.html#55">Source</a> </span></div><pre class="rust item-decl"><code>pub type NodeId = <a class="struct" href="struct.PublicKey.html" title="struct iroh::PublicKey">PublicKey</a>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The identifier for a node in the (iroh) network.</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="The identifier for a node in the (iroh) network."><title>NodeId in iroh - 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" 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 type"><!--[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/index.html">iroh</a><span class="version">0.33.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">NodeId</a></h2><h3><a href="#aliased-type">Aliased type</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate iroh</a></h2></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</a></span><h1>Type Alias <span class="type">NodeId</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub type NodeId = <a class="struct" href="struct.PublicKey.html" title="struct iroh::PublicKey">PublicKey</a>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The identifier for a node in the (iroh) network.</p>
<p>Each node in iroh has a unique identifier created as a cryptographic key. This can be
used to globally identify a node. Since it is also a cryptographic key it is also the
mechanism by which all traffic is always encrypted for a specific node only.</p>
@@ -989,8 +989,8 @@
<span class="kw">let </span><span class="kw-2">mut </span>got_ids = BTreeSet::new();
<span class="kw">while </span>got_ids.len() != num_nodes {
<span class="kw">if let </span><span class="prelude-val">Some</span>(item) = events.next().<span class="kw">await </span>{
<span class="kw">if </span>node_ids.contains(<span class="kw-2">&amp;</span>(item.node_id(), item.user_data().cloned())) {
got_ids.insert((item.node_id(), item.user_data().cloned()));
<span class="kw">if </span>node_ids.contains(<span class="kw-2">&amp;</span>(item.node_id(), item.user_data())) {
got_ids.insert((item.node_id(), item.user_data()));
}
} <span class="kw">else </span>{
<span class="macro">anyhow::bail!</span>(
+34 -54
View File
@@ -4688,17 +4688,7 @@
<a href="#4687" id="4687">4687</a>
<a href="#4688" id="4688">4688</a>
<a href="#4689" id="4689">4689</a>
<a href="#4690" id="4690">4690</a>
<a href="#4691" id="4691">4691</a>
<a href="#4692" id="4692">4692</a>
<a href="#4693" id="4693">4693</a>
<a href="#4694" id="4694">4694</a>
<a href="#4695" id="4695">4695</a>
<a href="#4696" id="4696">4696</a>
<a href="#4697" id="4697">4697</a>
<a href="#4698" id="4698">4698</a>
<a href="#4699" id="4699">4699</a>
<a href="#4700" id="4700">4700</a></pre></div><pre class="rust"><code><span class="doccomment">//! Implements a socket that can change its communication path while in use, actively searching for the best way to communicate.
<a href="#4690" id="4690">4690</a></pre></div><pre class="rust"><code><span class="doccomment">//! Implements a socket that can change its communication path while in use, actively searching for the best way to communicate.
//!
//! Based on tailscale/wgengine/magicsock
//!
@@ -4745,8 +4735,9 @@
<span class="kw">use </span>net_report::IpMappedAddresses;
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">use </span>net_report::{IpMappedAddr, QuicConfig};
<span class="kw">use </span>netwatch::{interfaces, netmon};
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">use </span>netwatch::{interfaces, ip::LocalAddresses, netmon, UdpSocket};
</span><span class="kw">use </span>netwatch::{ip::LocalAddresses, UdpSocket};
<span class="kw">use </span>quinn::{AsyncUdpSocket, ServerConfig};
<span class="kw">use </span>rand::{seq::SliceRandom, Rng, SeedableRng};
<span class="kw">use </span>relay_actor::RelaySendItem;
@@ -6525,8 +6516,7 @@
}
});
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span>network_monitor = netmon::Monitor::new().<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let </span>network_monitor = netmon::Monitor::new().<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let </span>qad_endpoint = endpoint.clone();
<span class="comment">// create a client config for the endpoint to use for QUIC address discovery
@@ -6570,8 +6560,7 @@
</span>sockets: actor_sockets,
no_v4_send: <span class="bool-val">false</span>,
net_reporter,
<span class="attr">#[cfg(not(wasm_browser))]
</span>network_monitor,
network_monitor,
net_report_config,
};
@@ -7038,8 +7027,7 @@
<span class="doccomment">/// The prober that discovers local network conditions, including the closest relay relay and NAT mappings.
</span>net_reporter: net_report::Client,
<span class="attr">#[cfg(not(wasm_browser))]
</span>network_monitor: netmon::Monitor,
network_monitor: netmon::Monitor,
}
<span class="doccomment">/// Actor state that relies on sockets being available.
@@ -7125,10 +7113,8 @@
<span class="kw">impl </span>Actor {
<span class="kw">async fn </span>run(<span class="kw-2">mut </span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;()&gt; {
<span class="comment">// Setup network monitoring
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span>(link_change_s, <span class="kw-2">mut </span>link_change_r) = mpsc::channel(<span class="number">8</span>);
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span>_token = <span class="self">self
<span class="kw">let </span>_token = <span class="self">self
</span>.network_monitor
.subscribe(<span class="kw">move </span>|is_major| {
<span class="kw">let </span>link_change_s = link_change_s.clone();
@@ -7173,11 +7159,6 @@
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>direct_addr_heartbeat_timer_tick = n0_future::future::pending();
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span>link_change_r_recv = link_change_r.recv();
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>link_change_r_recv = n0_future::future::pending();
<span class="macro">tokio::select!</span> {
msg = <span class="self">self</span>.msg_receiver.recv(), <span class="kw">if </span>!receiver_closed =&gt; {
<span class="kw">let </span><span class="prelude-val">Some</span>(msg) = msg <span class="kw">else </span>{
@@ -7242,23 +7223,18 @@
<span class="self">self</span>.refresh_direct_addrs(reason).<span class="kw">await</span>;
}
}
is_major = link_change_r_recv, <span class="kw">if </span>!link_change_closed =&gt; {
<span class="attr">#[cfg(not(wasm_browser))]
</span>{
<span class="kw">let </span><span class="prelude-val">Some</span>(is_major) = is_major <span class="kw">else </span>{
<span class="macro">trace!</span>(<span class="string">"tick: link change receiver closed"</span>);
<span class="macro">inc!</span>(Metrics, actor_tick_other);
is_major = link_change_r.recv(), <span class="kw">if </span>!link_change_closed =&gt; {
<span class="kw">let </span><span class="prelude-val">Some</span>(is_major) = is_major <span class="kw">else </span>{
<span class="macro">trace!</span>(<span class="string">"tick: link change receiver closed"</span>);
<span class="macro">inc!</span>(Metrics, actor_tick_other);
link_change_closed = <span class="bool-val">true</span>;
<span class="kw">continue</span>;
};
link_change_closed = <span class="bool-val">true</span>;
<span class="kw">continue</span>;
};
<span class="macro">trace!</span>(<span class="string">"tick: link change {}"</span>, is_major);
<span class="macro">inc!</span>(Metrics, actor_link_change);
<span class="self">self</span>.handle_network_change(is_major).<span class="kw">await</span>;
}
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>_unused_in_browsers = is_major;
<span class="macro">trace!</span>(<span class="string">"tick: link change {}"</span>, is_major);
<span class="macro">inc!</span>(Metrics, actor_link_change);
<span class="self">self</span>.handle_network_change(is_major).<span class="kw">await</span>;
}
<span class="comment">// Even if `discovery_events` yields `None`, it could begin to yield
// `Some` again in the future, so we don't want to disable this branch
@@ -7282,20 +7258,22 @@
}
}
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">async fn </span>handle_network_change(<span class="kw-2">&amp;mut </span><span class="self">self</span>, is_major: bool) {
<span class="kw">async fn </span>handle_network_change(<span class="kw-2">&amp;mut </span><span class="self">self</span>, is_major: bool) {
<span class="macro">debug!</span>(<span class="string">"link change detected: major? {}"</span>, is_major);
<span class="kw">if </span>is_major {
<span class="kw">if let </span><span class="prelude-val">Err</span>(err) = <span class="self">self</span>.sockets.v4.rebind() {
<span class="macro">warn!</span>(<span class="string">"failed to rebind Udp IPv4 socket: {:?}"</span>, err);
};
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>socket) = <span class="self">self</span>.sockets.v6 {
<span class="kw">if let </span><span class="prelude-val">Err</span>(err) = socket.rebind() {
<span class="macro">warn!</span>(<span class="string">"failed to rebind Udp IPv6 socket: {:?}"</span>, err);
<span class="attr">#[cfg(not(wasm_browser))]
</span>{
<span class="kw">if let </span><span class="prelude-val">Err</span>(err) = <span class="self">self</span>.sockets.v4.rebind() {
<span class="macro">warn!</span>(<span class="string">"failed to rebind Udp IPv4 socket: {:?}"</span>, err);
};
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>socket) = <span class="self">self</span>.sockets.v6 {
<span class="kw">if let </span><span class="prelude-val">Err</span>(err) = socket.rebind() {
<span class="macro">warn!</span>(<span class="string">"failed to rebind Udp IPv6 socket: {:?}"</span>, err);
};
}
<span class="self">self</span>.msock.dns_resolver.clear_cache();
}
<span class="self">self</span>.msock.dns_resolver.clear_cache();
<span class="self">self</span>.msock.re_stun(<span class="string">"link-change-major"</span>);
<span class="self">self</span>.close_stale_relay_connections().<span class="kw">await</span>;
<span class="self">self</span>.reset_endpoint_states();
@@ -7349,8 +7327,7 @@
<span class="self">self</span>.finalize_direct_addrs_update(why);
}
ActorMessage::NetworkChange =&gt; {
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="self">self</span>.network_monitor.network_change().<span class="kw">await</span>.ok();
<span class="self">self</span>.network_monitor.network_change().<span class="kw">await</span>.ok();
}
<span class="attr">#[cfg(test)]
</span>ActorMessage::ForceNetworkChange(is_major) =&gt; {
@@ -7732,15 +7709,18 @@
/// The relay connections who's local endpoints no longer exist after a network change
/// will error out soon enough. Closing them eagerly speeds this up however and allows
/// re-establishing a relay connection faster.
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">async fn </span>close_stale_relay_connections(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="kw">let </span>ifs = interfaces::State::new().<span class="kw">await</span>;
<span class="kw">let </span>local_ips = ifs
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span>local_ips = ifs
.interfaces
.values()
.flat_map(|netif| netif.addrs())
.map(|ipnet| ipnet.addr())
.collect();
<span class="comment">// In browsers, we don't have this information. This will do the right thing in the ActiveRelayActor, though.
</span><span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">let </span>local_ips = Vec::new();
<span class="self">self</span>.send_relay_actor(RelayActorMessage::MaybeCloseRelaysOnRebind(local_ips));
}
@@ -1745,13 +1745,7 @@
<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></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
<a href="#1747" id="1747">1747</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
collections::{btree_map::Entry, BTreeSet, HashMap},
hash::Hash,
net::{IpAddr, SocketAddr},
@@ -2743,7 +2737,7 @@
<span class="kw">for </span>peer_sockaddr <span class="kw">in </span><span class="kw-2">&amp;</span>m.my_numbers {
<span class="kw">if let </span>IpAddr::V6(ip) = peer_sockaddr.ip() {
<span class="kw">if </span>is_unicast_link_local(ip) {
<span class="kw">if </span>netwatch::ip::is_unicast_link_local(ip) {
<span class="comment">// We send these out, but ignore them for now.
// TODO: teach the ping code to ping on all interfaces for these.
</span><span class="kw">continue</span>;
@@ -3193,12 +3187,6 @@
</span><span class="prelude-val">None</span>,
}
<span class="doccomment">/// Returns true if the address is a unicast address with link-local scope, as defined in RFC 4291.
</span><span class="comment">// Copied from std lib, not stable yet
</span><span class="kw">pub const fn </span>is_unicast_link_local(addr: std::net::Ipv6Addr) -&gt; bool {
(addr.segments()[<span class="number">0</span>] &amp; <span class="number">0xffc0</span>) == <span class="number">0xfe80
</span>}
<span class="attr">#[cfg(test)]
</span><span class="kw">mod </span>tests {
<span class="kw">use </span>std::{collections::BTreeMap, net::Ipv4Addr};
File diff suppressed because one or more lines are too long