wasm_browser only.Expand description
DNS node discovery for iroh
+pub struct DnsDiscovery { /* private fields */ }wasm_browser only.Expand description
DNS node discovery
+pub struct DnsDiscovery { /* private fields */ }wasm_browser only.Expand description
DNS node discovery
When asked to resolve a NodeId, this service performs a lookup in the Domain Name System (DNS).
It uses the Endpoint’s DNS resolver to query for TXT records under the domain
_iroh.<z32-node-id>.<origin-domain>:
The DNS resolver defaults to using the nameservers configured on the host system, but can be changed
with crate::endpoint::Builder::dns_resolver.
Implementations§
Source§impl DnsDiscovery
impl DnsDiscovery
Implementations§
Source§impl DnsDiscovery
impl DnsDiscovery
Sourcepub fn n0_dns() -> Self
pub fn n0_dns() -> Self
Creates a new DNS discovery using the iroh.link domain.
This uses the N0_DNS_NODE_ORIGIN_PROD domain.
§Usage during tests
For testing it is possible to use the N0_DNS_NODE_ORIGIN_STAGING domain
with DnsDiscovery::new. This would then use a hosted staging discovery
service for testing purposes.
Trait Implementations§
Trait Implementations§
Source§impl Debug for DnsDiscovery
impl Debug for DnsDiscovery
Source§impl Discovery for DnsDiscovery
impl Discovery for DnsDiscovery
Source§fn resolve(
&self,
ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html b/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
index f3942b76e5..333ca77213 100644
--- a/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
+++ b/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
@@ -1,4 +1,4 @@
-NAME in iroh::discovery::mdns - Rust pub const NAME: &str = "local.swarm.discovery";
Available on crate feature discovery-local-network only.Expand description
Name of this discovery service.
+NAME in iroh::discovery::mdns - Rust pub const NAME: &str = "local.swarm.discovery";
Available on crate feature discovery-local-network only.Expand description
Name of this discovery service.
Used as the provenance field in DiscoveryItems.
Used in the crate::endpoint::Source::Discovery enum variant as the name.
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/discovery/mdns/index.html b/pr/3161/docs/iroh/discovery/mdns/index.html
index 6c3ccc1cc7..b2ad22b8d5 100644
--- a/pr/3161/docs/iroh/discovery/mdns/index.html
+++ b/pr/3161/docs/iroh/discovery/mdns/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::mdns - Rust Available on crate feature discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
+iroh::discovery::mdns - Rust Available on crate feature discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
See the swarm-discovery crate for more details.
When MdnsDiscovery is enabled, it’s possible to get a list of the locally discovered nodes by filtering a list of RemoteInfos.
diff --git a/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html b/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
index 82cb951796..51f81b1439 100644
--- a/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
@@ -1,15 +1,15 @@
-MdnsDiscovery in iroh::discovery::mdns - Rust pub struct MdnsDiscovery { /* private fields */ }
Available on crate feature discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
-Implementations§
Source§impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
+MdnsDiscovery in iroh::discovery::mdns - Rust pub struct MdnsDiscovery { /* private fields */ }
Available on crate feature discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
+Implementations§
Source§impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
This starts a [Discoverer] that broadcasts your addresses and receives addresses from other nodes in your local network.
§Errors
Returns an error if the network does not allow ipv4 OR ipv6.
§Panics
This relies on [tokio::runtime::Handle::current] and will panic if called outside of the context of a tokio runtime.
-Trait Implementations§
Trait Implementations§
Source§impl Debug for MdnsDiscovery
Auto Trait Implementations§
§impl Freeze for MdnsDiscovery
§impl RefUnwindSafe for MdnsDiscovery
§impl Send for MdnsDiscovery
§impl Sync for MdnsDiscovery
§impl Unpin for MdnsDiscovery
§impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
Auto Trait Implementations§
§impl Freeze for MdnsDiscovery
§impl RefUnwindSafe for MdnsDiscovery
§impl Send for MdnsDiscovery
§impl Sync for MdnsDiscovery
§impl Unpin for MdnsDiscovery
§impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
index a831480331..54639262e6 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
This module contains pkarr-based node discovery for iroh which can use both pkarr
relay servers as well as the Mainline DHT directly. See the pkarr module for an
overview of pkarr.
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
index 2c53d1e0d7..6f34598156 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
@@ -1,17 +1,17 @@
-Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
+Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
By default, publishing to the DHT is enabled, and relay publishing is disabled.
-Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
+Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
Without a secret key, the node will not publish its address to the DHT.
-Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
-Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
-Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
-Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
-Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
-Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
+Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
+Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
+Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
+Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
+Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
+Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
index 50e4dd6544..b7d327539b 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
@@ -1,11 +1,11 @@
-DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
+DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
It stores node addresses in DNS records, signed by the node’s private key, and publishes
them to the BitTorrent Mainline DHT. See the pkarr module for more details.
This implements the Discovery trait to be used as a node discovery service which can
be used as both a publisher and resolver. Calling DhtDiscovery::publish will start
a background task that periodically publishes the node address.
-Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
-Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
+Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Source§fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
fn resolve(
&self,
ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html b/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
index f3942b76e5..333ca77213 100644
--- a/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
+++ b/pr/3161/docs/iroh/discovery/mdns/constant.NAME.html
@@ -1,4 +1,4 @@
-NAME in iroh::discovery::mdns - Rust pub const NAME: &str = "local.swarm.discovery";
Available on crate feature discovery-local-network only.Expand description
Name of this discovery service.
+NAME in iroh::discovery::mdns - Rust pub const NAME: &str = "local.swarm.discovery";
Available on crate feature discovery-local-network only.Expand description
Name of this discovery service.
Used as the provenance field in DiscoveryItems.
Used in the crate::endpoint::Source::Discovery enum variant as the name.
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/discovery/mdns/index.html b/pr/3161/docs/iroh/discovery/mdns/index.html
index 6c3ccc1cc7..b2ad22b8d5 100644
--- a/pr/3161/docs/iroh/discovery/mdns/index.html
+++ b/pr/3161/docs/iroh/discovery/mdns/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::mdns - Rust Available on crate feature discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
+iroh::discovery::mdns - Rust Available on crate feature discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
See the swarm-discovery crate for more details.
When MdnsDiscovery is enabled, it’s possible to get a list of the locally discovered nodes by filtering a list of RemoteInfos.
diff --git a/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html b/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
index 82cb951796..51f81b1439 100644
--- a/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/mdns/struct.MdnsDiscovery.html
@@ -1,15 +1,15 @@
-MdnsDiscovery in iroh::discovery::mdns - Rust pub struct MdnsDiscovery { /* private fields */ }
Available on crate feature discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
-Implementations§
Source§impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
+MdnsDiscovery in iroh::discovery::mdns - Rust pub struct MdnsDiscovery { /* private fields */ }
Available on crate feature discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
+Implementations§
Source§impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
This starts a [Discoverer] that broadcasts your addresses and receives addresses from other nodes in your local network.
§Errors
Returns an error if the network does not allow ipv4 OR ipv6.
§Panics
This relies on [tokio::runtime::Handle::current] and will panic if called outside of the context of a tokio runtime.
-Trait Implementations§
Trait Implementations§
Source§impl Debug for MdnsDiscovery
Auto Trait Implementations§
§impl Freeze for MdnsDiscovery
§impl RefUnwindSafe for MdnsDiscovery
§impl Send for MdnsDiscovery
§impl Sync for MdnsDiscovery
§impl Unpin for MdnsDiscovery
§impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
Auto Trait Implementations§
§impl Freeze for MdnsDiscovery
§impl RefUnwindSafe for MdnsDiscovery
§impl Send for MdnsDiscovery
§impl Sync for MdnsDiscovery
§impl Unpin for MdnsDiscovery
§impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
index a831480331..54639262e6 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
This module contains pkarr-based node discovery for iroh which can use both pkarr
relay servers as well as the Mainline DHT directly. See the pkarr module for an
overview of pkarr.
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
index 2c53d1e0d7..6f34598156 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
@@ -1,17 +1,17 @@
-Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
+Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
By default, publishing to the DHT is enabled, and relay publishing is disabled.
-Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
+Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
Without a secret key, the node will not publish its address to the DHT.
-Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
-Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
-Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
-Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
-Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
-Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
+Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
+Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
+Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
+Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
+Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
+Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
index 50e4dd6544..b7d327539b 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
@@ -1,11 +1,11 @@
-DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
+DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
It stores node addresses in DNS records, signed by the node’s private key, and publishes
them to the BitTorrent Mainline DHT. See the pkarr module for more details.
This implements the Discovery trait to be used as a node discovery service which can
be used as both a publisher and resolver. Calling DhtDiscovery::publish will start
a background task that periodically publishes the node address.
-Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
-Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
+Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Source§fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
pub const NAME: &str = "local.swarm.discovery";discovery-local-network only.Expand description
Name of this discovery service.
+pub const NAME: &str = "local.swarm.discovery";discovery-local-network only.Expand description
Name of this discovery service.
Used as the provenance field in DiscoveryItems.
Used in the crate::endpoint::Source::Discovery enum variant as the name.
discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
+discovery-local-network only.Expand description
A discovery service that uses an mdns-like service to discover local nodes.
This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
See the swarm-discovery crate for more details.
When MdnsDiscovery is enabled, it’s possible to get a list of the locally discovered nodes by filtering a list of RemoteInfos.
pub struct MdnsDiscovery { /* private fields */ }discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
Implementations§
Source§impl MdnsDiscovery
impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
pub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
pub struct MdnsDiscovery { /* private fields */ }discovery-local-network only.Expand description
Discovery using swarm-discovery, a variation on mdns
Implementations§
Source§impl MdnsDiscovery
impl MdnsDiscovery
Sourcepub fn new(node_id: NodeId) -> Result<Self>
pub fn new(node_id: NodeId) -> Result<Self>
Create a new MdnsDiscovery Service.
This starts a [Discoverer] that broadcasts your addresses and receives addresses from other nodes in your local network.
§Errors
Returns an error if the network does not allow ipv4 OR ipv6.
§Panics
This relies on [tokio::runtime::Handle::current] and will panic if called outside of the context of a tokio runtime.
Trait Implementations§
Trait Implementations§
Source§impl Debug for MdnsDiscovery
impl Debug for MdnsDiscovery
Auto Trait Implementations§
impl Freeze for MdnsDiscovery
impl RefUnwindSafe for MdnsDiscovery
impl Send for MdnsDiscovery
impl Sync for MdnsDiscovery
impl Unpin for MdnsDiscovery
impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
Auto Trait Implementations§
impl Freeze for MdnsDiscovery
impl RefUnwindSafe for MdnsDiscovery
impl Send for MdnsDiscovery
impl Sync for MdnsDiscovery
impl Unpin for MdnsDiscovery
impl UnwindSafe for MdnsDiscovery
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
index a831480331..54639262e6 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+iroh::discovery::pkarr::dht - Rust Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
This module contains pkarr-based node discovery for iroh which can use both pkarr
relay servers as well as the Mainline DHT directly. See the pkarr module for an
overview of pkarr.
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
index 2c53d1e0d7..6f34598156 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html
@@ -1,17 +1,17 @@
-Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
+Builder in iroh::discovery::pkarr::dht - Rust pub struct Builder { /* private fields */ }
Available on crate feature discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
By default, publishing to the DHT is enabled, and relay publishing is disabled.
-Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
+Implementations§
Source§impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
Without a secret key, the node will not publish its address to the DHT.
-Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
-Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
-Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
-Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
-Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
-Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
+Sourcepub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
+Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
+Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
+Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
+Sourcepub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
+Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Builder
§impl !RefUnwindSafe for Builder
§impl Send for Builder
§impl Sync for Builder
§impl Unpin for Builder
§impl !UnwindSafe for Builder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
index 50e4dd6544..b7d327539b 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
@@ -1,11 +1,11 @@
-DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
+DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
It stores node addresses in DNS records, signed by the node’s private key, and publishes
them to the BitTorrent Mainline DHT. See the pkarr module for more details.
This implements the Discovery trait to be used as a node discovery service which can
be used as both a publisher and resolver. Calling DhtDiscovery::publish will start
a background task that periodically publishes the node address.
-Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
-Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
+Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Source§fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+discovery-pkarr-dht only.Expand description
Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
This module contains pkarr-based node discovery for iroh which can use both pkarr relay servers as well as the Mainline DHT directly. See the pkarr module for an overview of pkarr.
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html index 2c53d1e0d7..6f34598156 100644 --- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html +++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.Builder.html @@ -1,17 +1,17 @@ -pub struct Builder { /* private fields */ }discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
pub struct Builder { /* private fields */ }discovery-pkarr-dht only.Expand description
Builder for DhtDiscovery.
By default, publishing to the DHT is enabled, and relay publishing is disabled.
-Implementations§
Source§impl Builder
impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
pub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
+Implementations§
Source§impl Builder
impl Builder
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
pub fn secret_key(self, secret_key: SecretKey) -> Self
Sets the secret key to use for signing the DNS packets.
Without a secret key, the node will not publish its address to the DHT.
-Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
pub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
-Sourcepub fn n0_dns_pkarr_relay(self) -> Self
pub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
-Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
pub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
-Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
pub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
-Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
pub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
-Sourcepub fn build(self) -> Result<DhtDiscovery>
pub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
-Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
Sourcepub fn pkarr_relay(self, pkarr_relay: Url) -> Self
pub fn pkarr_relay(self, pkarr_relay: Url) -> Self
Sets the pkarr relay URL to use.
+Sourcepub fn n0_dns_pkarr_relay(self) -> Self
pub fn n0_dns_pkarr_relay(self) -> Self
Uses the default number 0 pkarr relay URL.
+Sourcepub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
pub fn include_direct_addresses(self, include_direct_addresses: bool) -> Self
Sets whether to include the direct addresses in the DNS packet.
+Sourcepub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
pub fn initial_publish_delay(self, initial_publish_delay: Duration) -> Self
Sets the initial delay before the first publish.
+Sourcepub fn republish_delay(self, republish_delay: Duration) -> Self
pub fn republish_delay(self, republish_delay: Duration) -> Self
Sets the republish delay for the DHT.
+Sourcepub fn build(self) -> Result<DhtDiscovery>
pub fn build(self) -> Result<DhtDiscovery>
Builds the discovery mechanism.
+Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
index 50e4dd6544..b7d327539b 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/dht/struct.DhtDiscovery.html
@@ -1,11 +1,11 @@
-DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
+DhtDiscovery in iroh::discovery::pkarr::dht - Rust pub struct DhtDiscovery(/* private fields */);
Available on crate feature discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
It stores node addresses in DNS records, signed by the node’s private key, and publishes
them to the BitTorrent Mainline DHT. See the pkarr module for more details.
This implements the Discovery trait to be used as a node discovery service which can
be used as both a publisher and resolver. Calling DhtDiscovery::publish will start
a background task that periodically publishes the node address.
-Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
-Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Implementations§
Source§impl DhtDiscovery
Sourcepub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
+Trait Implementations§
Source§impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
Source§fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
pub struct DhtDiscovery(/* private fields */);discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
+pub struct DhtDiscovery(/* private fields */);discovery-pkarr-dht only.Expand description
Pkarr Mainline DHT and relay server node discovery.
It stores node addresses in DNS records, signed by the node’s private key, and publishes them to the BitTorrent Mainline DHT. See the pkarr module for more details.
This implements the Discovery trait to be used as a node discovery service which can
be used as both a publisher and resolver. Calling DhtDiscovery::publish will start
a background task that periodically publishes the node address.
Implementations§
Source§impl DhtDiscovery
impl DhtDiscovery
Sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
Trait Implementations§
Source§impl Clone for DhtDiscovery
impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
fn clone(&self) -> DhtDiscovery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DhtDiscovery
impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
impl Discovery for DhtDiscovery
Implementations§
Source§impl DhtDiscovery
impl DhtDiscovery
Sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder for DhtDiscovery.
Trait Implementations§
Source§impl Clone for DhtDiscovery
impl Clone for DhtDiscovery
Source§fn clone(&self) -> DhtDiscovery
fn clone(&self) -> DhtDiscovery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DhtDiscovery
impl Debug for DhtDiscovery
Source§impl Default for DhtDiscovery
impl Default for DhtDiscovery
Source§impl Discovery for DhtDiscovery
impl Discovery for DhtDiscovery
Source§fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
fn resolve(
&self,
_endpoint: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/pkarr/index.html b/pr/3161/docs/iroh/discovery/pkarr/index.html
index 176db35e8b..21a8b5cd7f 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/index.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/index.html
@@ -1,4 +1,4 @@
-iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+iroh::discovery::pkarr - Rust Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
-Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
+Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
\ No newline at end of file
diff --git a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
index 4f504f8eb7..0d17ff6d02 100644
--- a/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
+++ b/pr/3161/docs/iroh/net_report/fn.bind_local_stun_socket.html
@@ -1,4 +1,4 @@
-bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);
Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
+Expand description
A discovery service which publishes and resolves node information using a pkarr relay.
Public-Key Addressable Resource Records, pkarr, is a system which allows publishing
DNS Resource Records owned by a particular SecretKey under a name derived from its
corresponding PublicKey, also known as the NodeId. Additionally this pkarr
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
index 8ae2dcb36f..85b7d86762 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrRelayClient.html
@@ -1,8 +1,8 @@
-
pub struct PkarrRelayClient { /* private fields */ }Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
fn clone(&self) -> PkarrRelayClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PkarrRelayClient
impl !RefUnwindSafe for PkarrRelayClient
impl Send for PkarrRelayClient
impl Sync for PkarrRelayClient
impl Unpin for PkarrRelayClient
impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
Source§impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
impl<T> Any for Twhere
+PkarrRelayClient in iroh::discovery::pkarr - Rust pub struct PkarrRelayClient { /* private fields */ }
Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
+Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreAuto Trait Implementations§
§impl Freeze for PkarrRelayClient
§impl !RefUnwindSafe for PkarrRelayClient
§impl Send for PkarrRelayClient
§impl Sync for PkarrRelayClient
§impl Unpin for PkarrRelayClient
§impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Trait Implementations§
Source§impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
Implementors§
Source§impl Discovery for DnsDiscovery
Available on non-wasm_browser only. Source§impl Discovery for MdnsDiscovery
Available on crate feature discovery-local-network only. Source§impl Discovery for DhtDiscovery
Available on crate feature discovery-pkarr-dht only. Source§impl Discovery for PkarrPublisher
Source§impl Discovery for PkarrResolver
Source§impl Discovery for StaticProvider
Source§impl Discovery for ConcurrentDiscovery
pub struct PkarrRelayClient { /* private fields */ }Expand description
A pkarr client to publish [pkarr::SignedPacket]s to a pkarr relay.
Implementations§
Trait Implementations§
Source§impl Clone for PkarrRelayClient
impl Clone for PkarrRelayClient
Source§fn clone(&self) -> PkarrRelayClient
fn clone(&self) -> PkarrRelayClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PkarrRelayClient
impl !RefUnwindSafe for PkarrRelayClient
impl Send for PkarrRelayClient
impl Sync for PkarrRelayClient
impl Unpin for PkarrRelayClient
impl !UnwindSafe for PkarrRelayClient
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
fn implicit(
diff --git a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
index 9f7473c7cb..e5cf470bde 100644
--- a/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
+++ b/pr/3161/docs/iroh/discovery/pkarr/struct.PkarrResolver.html
@@ -11,7 +11,7 @@ the N0_DNS_PKARR_RELAY_STAGING
server is used instead.
-
Trait Implementations§
Source§impl Clone for PkarrResolver
impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
fn clone(&self) -> PkarrResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PkarrResolver
impl Debug for PkarrResolver
Source§impl Clone for PkarrResolver
impl Clone for PkarrResolver
Source§fn clone(&self) -> PkarrResolver
fn clone(&self) -> PkarrResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PkarrResolver
impl Debug for PkarrResolver
Source§impl Discovery for PkarrResolver
impl Discovery for PkarrResolver
Source§fn resolve(
&self,
_ep: Endpoint,
node_id: NodeId,
diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html
index 6caa9af236..ae10e01262 100644
--- a/pr/3161/docs/iroh/discovery/trait.Discovery.html
+++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html
@@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
-
fn resolve( &self, _ep: Endpoint, node_id: NodeId, diff --git a/pr/3161/docs/iroh/discovery/trait.Discovery.html b/pr/3161/docs/iroh/discovery/trait.Discovery.html index 6caa9af236..ae10e01262 100644 --- a/pr/3161/docs/iroh/discovery/trait.Discovery.html +++ b/pr/3161/docs/iroh/discovery/trait.Discovery.html @@ -50,4 +50,4 @@ should be sent on all streams.
The crate::endpoint::Endpoint will subscribe to the discovery system
and add the discovered addresses to the internal address book as they arrive
on this stream.
impl<T: Discovery> Discovery for Arc<T>
impl Discovery for DnsDiscovery
wasm_browser only.impl Discovery for MdnsDiscovery
discovery-local-network only.impl Discovery for DhtDiscovery
discovery-pkarr-dht only.impl Discovery for PkarrPublisher
impl Discovery for PkarrResolver
impl Discovery for StaticProvider
impl Discovery for ConcurrentDiscovery
Implementations on Foreign Types§
impl<T: Discovery> Discovery for Arc<T>
Implementors§
impl Discovery for DnsDiscovery
wasm_browser only.impl Discovery for MdnsDiscovery
discovery-local-network only.impl Discovery for DhtDiscovery
discovery-pkarr-dht only.impl Discovery for PkarrPublisher
impl Discovery for PkarrResolver
impl Discovery for StaticProvider
impl Discovery for ConcurrentDiscovery
pub fn bind_local_stun_socket(
+bind_local_stun_socket in iroh::net_report - Rust pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: Addr,
cancel_token: CancellationToken,
diff --git a/pr/3161/docs/iroh/net_report/index.html b/pr/3161/docs/iroh/net_report/index.html
index 5dcfa9fe14..c02238adf3 100644
--- a/pr/3161/docs/iroh/net_report/index.html
+++ b/pr/3161/docs/iroh/net_report/index.html
@@ -1,4 +1,4 @@
-iroh::net_report - Rust Expand description
Checks the network conditions from the current host.
+iroh::net_report - Rust Expand description
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
etc and reachability to the configured relays.
diff --git a/pr/3161/docs/iroh/net_report/struct.Addr.html b/pr/3161/docs/iroh/net_report/struct.Addr.html
index 1640916e18..00d4ed72d6 100644
--- a/pr/3161/docs/iroh/net_report/struct.Addr.html
+++ b/pr/3161/docs/iroh/net_report/struct.Addr.html
@@ -1,7 +1,7 @@
-Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
+Addr in iroh::net_report - Rust pub struct Addr { /* private fields */ }
Expand description
Sender to the main service.
Unlike Client this is the raw channel to send messages over. Keeping this alive
will not keep the actor alive, which makes this handy to pass to internal tasks.
-Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
+Implementations§
Source§impl Addr
Sourcepub fn receive_stun_packet(&self, payload: Bytes, src: SocketAddr)
Pass a received STUN packet to the net_reporter.
Normally the UDP sockets to send STUN messages from are passed in so that STUN
packets are sent from the sockets that carry the real traffic. However because
these sockets carry real traffic they will also receive non-STUN traffic, thus the
@@ -11,7 +11,7 @@ packet on the socket you should pass it to this method.
in-flight STUN probes. The actor will simply ignore any stray STUN packets.
There is an implicit queue here which may drop packets if the actor does not keep up
consuming them.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Addr
§impl RefUnwindSafe for Addr
§impl Send for Addr
§impl Sync for Addr
§impl Unpin for Addr
§impl UnwindSafe for Addr
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/net_report/struct.Client.html b/pr/3161/docs/iroh/net_report/struct.Client.html
index 0d963fafc5..c994e96d47 100644
--- a/pr/3161/docs/iroh/net_report/struct.Client.html
+++ b/pr/3161/docs/iroh/net_report/struct.Client.html
@@ -5,7 +5,7 @@ it is idle unless Clients are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet.
- Implementations§
Implementations§
Source§impl Client
Sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver,
ip_mapped_addrs: Option<IpMappedAddresses>,
@@ -15,7 +15,7 @@ stop running.
Sourcepub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr does not own the actor task, it only
allows sending messages to the actor.
-Sourcepub async fn get_report(
+
Sourcepub async fn get_report(
&mut self,
relay_map: RelayMap,
opts: Options,
diff --git a/pr/3161/docs/iroh/protocol/index.html b/pr/3161/docs/iroh/protocol/index.html
index 4da9ff14f0..033fefb41c 100644
--- a/pr/3161/docs/iroh/protocol/index.html
+++ b/pr/3161/docs/iroh/protocol/index.html
@@ -1,4 +1,4 @@
-iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
+iroh::protocol - Rust Expand description
Tools for spawning an accept loop that routes incoming requests to the right protocol.
§Example
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
diff --git a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
index 5a5e9afd90..c621fa1077 100644
--- a/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3161/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,12 +1,12 @@
-AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
+
AccessLimit in iroh::protocol - Rust pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description
Wraps an existing protocol, limiting its access,
based on the provided function.
Any refused connection will be closed with an error code of 0 and reason not allowed.
-Implementations§
Source§impl<P: ProtocolHandler + Clone> AccessLimit<P>
Implementations§
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
+
Trait Implementations§
Source§impl<P: Clone + ProtocolHandler + Clone> Clone for AccessLimit<P>
Source§fn clone(&self) -> AccessLimit<P>
Returns a copy of the value. Read more1.0.0 · Source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read moreSource§impl<P> Debug for AccessLimit<P>
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state. Read moreAuto Trait Implementations§
§impl<P> Freeze for AccessLimit<P>where
P: Freeze,
§impl<P> !RefUnwindSafe for AccessLimit<P>
§impl<P> Send for AccessLimit<P>
§impl<P> Sync for AccessLimit<P>
§impl<P> Unpin for AccessLimit<P>where
P: Unpin,
§impl<P> !UnwindSafe for AccessLimit<P>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
diff --git a/pr/3161/docs/iroh/protocol/struct.Router.html b/pr/3161/docs/iroh/protocol/struct.Router.html
index 18bcb97767..abdafe98e8 100644
--- a/pr/3161/docs/iroh/protocol/struct.Router.html
+++ b/pr/3161/docs/iroh/protocol/struct.Router.html
@@ -1,4 +1,4 @@
-Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
+Router in iroh::protocol - Rust pub struct Router { /* private fields */ }
Expand description
The built router.
Construct this using Router::builder.
When dropped, this will abort listening the tasks, so make sure to store it.
Even with this abort-on-drop behaviour, it’s recommended to call and await
@@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:
// wait until the user wants to
tokio::signal::ctrl_c().await?;
router.shutdown().await?;
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
-Implementations§
Source§impl Router
Sourcepub fn builder(endpoint: Endpoint) -> RouterBuilder
Sourcepub fn is_shutdown(&self) -> bool
Checks if the router is already shutdown.
+Sourcepub async fn shutdown(&self) -> Result<()>
Shuts down the accept loop cleanly.
When this function returns, all ProtocolHandlers will be shutdown and
Endpoint::close will have been called.
If already shutdown, it returns Ok.
If some ProtocolHandler panicked in the accept loop, this will propagate
that panic into the result here.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for Router
§impl !RefUnwindSafe for Router
§impl Send for Router
§impl Sync for Router
§impl Unpin for Router
§impl !UnwindSafe for Router
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
index 50abe1eca4..ee80fc798a 100644
--- a/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
+++ b/pr/3161/docs/iroh/protocol/struct.RouterBuilder.html
@@ -1,14 +1,14 @@
-RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
-Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
+RouterBuilder in iroh::protocol - Rust pub struct RouterBuilder { /* private fields */ }
Expand description
Builder for creating a Router for accepting protocols.
+Implementations§
Source§impl RouterBuilder
Sourcepub fn accept<T: ProtocolHandler>(
self,
alpn: impl AsRef<[u8]>,
handler: T,
) -> Self
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
-Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
Trait Implementations§
Auto Trait Implementations§
§impl Freeze for RouterBuilder
§impl !RefUnwindSafe for RouterBuilder
§impl Send for RouterBuilder
§impl Sync for RouterBuilder
§impl Unpin for RouterBuilder
§impl !UnwindSafe for RouterBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§fn implicit(
diff --git a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
index 60307606ca..a6c7099d8f 100644
--- a/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
+++ b/pr/3161/docs/iroh/protocol/trait.ProtocolHandler.html
@@ -1,4 +1,4 @@
-ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
+ProtocolHandler in iroh::protocol - Rust pub trait ProtocolHandler:
Send
+ Sync
+ Debug
@@ -18,9 +18,9 @@
Implement this trait on a struct that should handle incoming connections.
The protocol handler must then be registered on the node for an ALPN protocol with
crate::protocol::RouterBuilder::accept.
-
Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
+Required Methods§
Sourcefn accept(&self, connection: Connection) -> BoxFuture<Result<()>>
Handle an incoming connection.
This runs on a freshly spawned tokio task so this can be long-running.
-Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
+Provided Methods§
Sourcefn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>>
Optional interception point to handle the Connecting state.
This enables accepting 0-RTT data from clients, among other things.
-Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
+
Implementations on Foreign Types§
Source§impl<T: ProtocolHandler> ProtocolHandler for Box<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Source§impl<T: ProtocolHandler> ProtocolHandler for Arc<T>
Source§fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>>
Source§fn accept(&self, conn: Connection) -> BoxFuture<Result<()>>
Source§fn shutdown(&self) -> BoxFuture<()>
Implementors§
Source§impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>
\ No newline at end of file
diff --git a/pr/3161/docs/src/iroh/discovery/dns.rs.html b/pr/3161/docs/src/iroh/discovery/dns.rs.html
index 08160fe777..b497f01c9e 100644
--- a/pr/3161/docs/src/iroh/discovery/dns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/dns.rs.html
@@ -76,10 +76,12 @@
75
76
77
-78
//! DNS node discovery for iroh
+78
+79
+80
+81
//! DNS node discovery for iroh
-use anyhow::Result;
-use iroh_base::NodeId;
+use iroh_base::NodeId;
pub use iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
use n0_future::boxed::BoxStream;
@@ -141,7 +143,11 @@
}
impl Discovery for DnsDiscovery {
- fn resolve(&self, ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let resolver = ep.dns_resolver().clone();
let origin_domain = self.origin_domain.clone();
let fut = async move {
diff --git a/pr/3161/docs/src/iroh/discovery/mdns.rs.html b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
index aba8cf1a83..fa1411c4ed 100644
--- a/pr/3161/docs/src/iroh/discovery/mdns.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/mdns.rs.html
@@ -501,7 +501,10 @@
500
501
502
-503
//! A discovery service that uses an mdns-like service to discover local nodes.
+503
+504
+505
+506
//! A discovery service that uses an mdns-like service to discover local nodes.
//!
//! This allows you to use an mdns-like swarm discovery service to find address information about nodes that are on your local network, no relay or outside internet needed.
//! See the [`swarm-discovery`](https://crates.io/crates/swarm-discovery) crate for more details.
@@ -538,7 +541,6 @@
net::{IpAddr, SocketAddr},
};
-use anyhow::Result;
use derive_more::FromStr;
use iroh_base::{NodeId, PublicKey};
use n0_future::{
@@ -586,7 +588,7 @@
#[derive(Debug)]
enum Message {
Discovery(String, Peer),
- Resolve(NodeId, mpsc::Sender<Result<DiscoveryItem>>),
+ Resolve(NodeId, mpsc::Sender<anyhow::Result<DiscoveryItem>>),
Timeout(NodeId, usize),
Subscribe(mpsc::Sender<DiscoveryItem>),
}
@@ -641,7 +643,7 @@
///
/// # Panics
/// This relies on [`tokio::runtime::Handle::current`] and will panic if called outside of the context of a tokio runtime.
- pub fn new(node_id: NodeId) -> Result<Self> {
+ pub fn new(node_id: NodeId) -> anyhow::Result<Self> {
debug!("Creating new MdnsDiscovery service");
let (send, mut recv) = mpsc::channel(64);
let task_sender = send.clone();
@@ -657,7 +659,7 @@
let mut last_id = 0;
let mut senders: HashMap<
PublicKey,
- HashMap<usize, mpsc::Sender<Result<DiscoveryItem>>>,
+ HashMap<usize, mpsc::Sender<anyhow::Result<DiscoveryItem>>>,
> = HashMap::default();
let mut timeouts = JoinSet::new();
loop {
@@ -809,7 +811,7 @@
sender: mpsc::Sender<Message>,
socketaddrs: BTreeSet<SocketAddr>,
rt: &tokio::runtime::Handle,
- ) -> Result<DropGuard> {
+ ) -> anyhow::Result<DropGuard> {
let spawn_rt = rt.clone();
let callback = move |node_id: &str, peer: &Peer| {
trace!(
@@ -876,7 +878,11 @@
}
impl Discovery for MdnsDiscovery {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
use futures_util::FutureExt;
let (send, recv) = mpsc::channel(20);
@@ -998,7 +1004,7 @@
Ok(())
}
- fn make_discoverer() -> Result<(PublicKey, MdnsDiscovery)> {
+ fn make_discoverer() -> anyhow::Result<(PublicKey, MdnsDiscovery)> {
let node_id = SecretKey::generate(rand::thread_rng()).public();
Ok((node_id, MdnsDiscovery::new(node_id)?))
}
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
index 3cdd7126a4..786a3d1e05 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr.rs.html
@@ -402,7 +402,11 @@
401
402
403
-404
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
+404
+405
+406
+407
+408
//! A discovery service which publishes and resolves node information using a [pkarr] relay.
//!
//! Public-Key Addressable Resource Records, [pkarr], is a system which allows publishing
//! [DNS Resource Records] owned by a particular [`SecretKey`] under a name derived from its
@@ -450,7 +454,7 @@
use std::sync::Arc;
-use anyhow::{anyhow, bail, Result};
+use anyhow::{anyhow, bail};
use iroh_base::{NodeId, SecretKey};
use iroh_relay::node_info::NodeInfo;
use n0_future::{
@@ -667,7 +671,7 @@
}
}
- async fn publish_current(&self, info: NodeInfo) -> Result<()> {
+ async fn publish_current(&self, info: NodeInfo) -> anyhow::Result<()> {
debug!(
data = ?info.data,
pkarr_relay = %self.pkarr_client.pkarr_relay_url,
@@ -726,7 +730,11 @@
}
impl Discovery for PkarrResolver {
- fn resolve(&self, _ep: Endpoint, node_id: NodeId) -> Option<BoxStream<Result<DiscoveryItem>>> {
+ fn resolve(
+ &self,
+ _ep: Endpoint,
+ node_id: NodeId,
+ ) -> Option<BoxStream<anyhow::Result<DiscoveryItem>>> {
let pkarr_client = self.pkarr_client.clone();
let fut = async move {
let signed_packet = pkarr_client.resolve(node_id).await?;
diff --git a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
index cb2ab0bd40..c3526678c9 100644
--- a/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
+++ b/pr/3161/docs/src/iroh/discovery/pkarr/dht.rs.html
@@ -443,8 +443,7 @@
442
443
444
-445
-446
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
+445
//! Pkarr based node discovery for iroh, supporting both relay servers and the DHT.
//!
//! This module contains pkarr-based node discovery for iroh which can use both pkarr
//! relay servers as well as the Mainline DHT directly. See the [pkarr module] for an
@@ -453,7 +452,6 @@
//! [pkarr module]: super
use std::sync::{Arc, Mutex};
-use anyhow::Result;
use iroh_base::{NodeId, SecretKey};
use n0_future::{
boxed::BoxStream,
@@ -536,7 +534,7 @@
}
impl Inner {
- async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_relay(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from relay {:?}", key.to_z32(), self.relay_url);
let maybe_packet = self
@@ -566,7 +564,7 @@
}
}
}
- async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<Result<DiscoveryItem>> {
+ async fn resolve_dht(&self, key: pkarr::PublicKey) -> Option<anyhow::Result<DiscoveryItem>> {
tracing::info!("resolving {} from DHT", key.to_z32());
let maybe_packet = self.pkarr.resolve(&key).await;
@@ -681,7 +679,7 @@
}
/// Builds the discovery mechanism.
- pub fn build(self) -> Result<DhtDiscovery> {
+ pub fn build(self) -> anyhow::Result<DhtDiscovery> {
let pkarr = match self.client {
Some(client) => client,
None => PkarrClient::new(Default::default())?,
diff --git a/pr/3161/docs/src/iroh/net_report.rs.html b/pr/3161/docs/src/iroh/net_report.rs.html
index 2deb7bfcd1..220e6e0b9d 100644
--- a/pr/3161/docs/src/iroh/net_report.rs.html
+++ b/pr/3161/docs/src/iroh/net_report.rs.html
@@ -1390,7 +1390,15 @@
1389
1390
1391
-1392
//! Checks the network conditions from the current host.
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
//! 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
@@ -1409,7 +1417,7 @@
sync::Arc,
};
-use anyhow::{anyhow, Result};
+use anyhow::anyhow;
use bytes::Bytes;
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
@@ -1641,7 +1649,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
let mut actor = Actor::new(
#[cfg(not(wasm_browser))]
port_mapper,
@@ -1698,7 +1706,7 @@
#[cfg(not(wasm_browser))] stun_sock_v4: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] stun_sock_v6: Option<Arc<UdpSocket>>,
#[cfg(not(wasm_browser))] quic_config: Option<QuicConfig>,
- ) -> Result<Arc<Report>> {
+ ) -> anyhow::Result<Arc<Report>> {
#[cfg(not(wasm_browser))]
let opts = Options::default()
.stun_v4(stun_sock_v4)
@@ -1718,7 +1726,11 @@
/// It may not be called concurrently with itself, `&mut self` takes care of that.
///
/// Look at [`Options`] for the different configuration options.
- pub async fn get_report(&mut self, relay_map: RelayMap, opts: Options) -> Result<Arc<Report>> {
+ pub async fn get_report(
+ &mut self,
+ relay_map: RelayMap,
+ opts: Options,
+ ) -> anyhow::Result<Arc<Report>> {
let rx = self.get_report_channel(relay_map, opts).await?;
match rx.await {
Ok(res) => res,
@@ -1733,7 +1745,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- ) -> Result<oneshot::Receiver<Result<Arc<Report>>>> {
+ ) -> anyhow::Result<oneshot::Receiver<anyhow::Result<Arc<Report>>>> {
let (tx, rx) = oneshot::channel();
self.addr
.send(Message::RunCheck {
@@ -1769,7 +1781,7 @@
/// Options for the report
opts: Options,
/// Channel to receive the response.
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
},
/// A report produced by the [`reportgen`] actor.
ReportReady { report: Box<Report> },
@@ -1883,7 +1895,7 @@
#[cfg(not(wasm_browser))] port_mapper: Option<portmapper::Client>,
#[cfg(not(wasm_browser))] dns_resolver: DnsResolver,
#[cfg(not(wasm_browser))] ip_mapped_addrs: Option<IpMappedAddresses>,
- ) -> Result<Self> {
+ ) -> anyhow::Result<Self> {
// TODO: consider an instrumented flume channel so we have metrics.
let (sender, receiver) = mpsc::channel(32);
Ok(Self {
@@ -1949,7 +1961,7 @@
&mut self,
relay_map: RelayMap,
opts: Options,
- response_tx: oneshot::Sender<Result<Arc<Report>>>,
+ response_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
) {
let protocols = opts.to_protocols();
#[cfg(not(wasm_browser))]
@@ -2172,7 +2184,7 @@
/// The handle of the [`reportgen`] actor, cancels the actor on drop.
_reportgen: reportgen::Client,
/// Where to send the completed report.
- report_tx: oneshot::Sender<Result<Arc<Report>>>,
+ report_tx: oneshot::Sender<anyhow::Result<Arc<Report>>>,
}
/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
@@ -2247,7 +2259,11 @@
}
/// Receive STUN response from a UDP socket, pass it to the actor.
- async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &Addr) -> Result<()> {
+ async fn recv_stun_once(
+ sock: &UdpSocket,
+ buf: &mut [u8],
+ actor_addr: &Addr,
+ ) -> anyhow::Result<()> {
let (count, mut from_addr) = sock
.recv_from(buf)
.await
@@ -2451,7 +2467,7 @@
#[tokio::test]
#[traced_test]
- async fn test_basic() -> Result<()> {
+ async fn test_basic() -> anyhow::Result<()> {
let (stun_addr, stun_stats, _cleanup_guard) =
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
@@ -2494,7 +2510,7 @@
#[tokio::test]
#[traced_test]
- async fn test_udp_blocked() -> Result<()> {
+ async fn test_udp_blocked() -> anyhow::Result<()> {
// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
@@ -2545,7 +2561,7 @@
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
- async fn test_add_report_history_set_preferred_relay() -> Result<()> {
+ async fn test_add_report_history_set_preferred_relay() -> anyhow::Result<()> {
fn relay_url(i: u16) -> RelayUrl {
format!("http://{i}.com").parse().unwrap()
}
@@ -2726,7 +2742,7 @@
}
#[tokio::test]
- async fn test_hairpin() -> Result<()> {
+ async fn test_hairpin() -> anyhow::Result<()> {
// Hairpinning is initiated after we discover our own IPv4 socket address (IP +
// port) via STUN, so the test needs to have a STUN server and perform STUN over
// IPv4 first. Hairpinning detection works by sending a STUN *request* to **our own
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
index eabc97d6b6..b61fcac2ac 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen.rs.html
@@ -1782,7 +1782,7 @@
task::{Context, Poll},
};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{anyhow, bail, Context as _};
use iroh_base::RelayUrl;
#[cfg(feature = "metrics")]
use iroh_metrics::inc;
@@ -2005,7 +2005,7 @@
/// - Receives actor messages (sent by those futures).
/// - Updates the report, cancels unneeded futures.
/// - Sends the report to the net_report actor.
- async fn run_inner(&mut self) -> Result<()> {
+ async fn run_inner(&mut self) -> anyhow::Result<()> {
#[cfg(not(wasm_browser))]
let port_mapper = self.socket_state.port_mapper.is_some();
#[cfg(wasm_browser)]
@@ -2329,7 +2329,7 @@
/// failure permanent. Probes in a probe set are essentially retries.
/// - Once there are [`ProbeReport`]s from enough nodes, all remaining probes are
/// aborted. That is, the main actor loop stops polling them.
- async fn spawn_probes_task(&mut self) -> Result<JoinSet<Result<ProbeReport>>> {
+ async fn spawn_probes_task(&mut self) -> anyhow::Result<JoinSet<anyhow::Result<ProbeReport>>> {
#[cfg(not(wasm_browser))]
let if_state = interfaces::State::new().await;
#[cfg(not(wasm_browser))]
@@ -2781,7 +2781,7 @@
dns_resolver: &DnsResolver,
dm: &RelayMap,
preferred_relay: Option<RelayUrl>,
-) -> Result<bool> {
+) -> anyhow::Result<bool> {
// If we have a preferred relay node and we can use it for non-STUN requests, try that;
// otherwise, pick a random one suitable for non-STUN requests.
let preferred_relay = preferred_relay.and_then(|url| match dm.get_node(&url) {
@@ -2859,7 +2859,7 @@
}
/// Returns the proper port based on the protocol of the probe.
-fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> Result<u16> {
+fn get_port(relay_node: &RelayNode, proto: &ProbeProto) -> anyhow::Result<u16> {
match proto {
#[cfg(not(wasm_browser))]
ProbeProto::QuicIpv4 | ProbeProto::QuicIpv6 => {
@@ -2898,7 +2898,7 @@
dns_resolver: &DnsResolver,
relay_node: &RelayNode,
proto: ProbeProto,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
if relay_node.stun_only && !matches!(proto, ProbeProto::StunIpv4 | ProbeProto::StunIpv6) {
bail!("Relay node not suitable for non-STUN probes");
}
@@ -2925,7 +2925,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS A lookup for relay addr");
@@ -2955,7 +2955,7 @@
dns_resolver: &DnsResolver,
relay: &RelayNode,
port: u16,
-) -> Result<SocketAddr> {
+) -> anyhow::Result<SocketAddr> {
match relay.url.host() {
Some(url::Host::Domain(hostname)) => {
debug!(%hostname, "Performing DNS AAAA lookup for relay addr");
@@ -3031,7 +3031,7 @@
#[cfg(not(wasm_browser))] dns_resolver: &DnsResolver,
node: &RelayNode,
certs: Option<Vec<rustls::pki_types::CertificateDer<'static>>>,
-) -> Result<(Duration, IpAddr)> {
+) -> anyhow::Result<(Duration, IpAddr)> {
let url = node.url.join(RELAY_PROBE_PATH)?;
// This should also use same connection establishment as relay client itself, which
diff --git a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
index f8f56ee420..977ca34967 100644
--- a/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
+++ b/pr/3161/docs/src/iroh/net_report/reportgen/probes.rs.html
@@ -1185,7 +1185,7 @@
use std::{collections::BTreeSet, fmt, sync::Arc};
-use anyhow::{ensure, Result};
+use anyhow::ensure;
use iroh_base::RelayUrl;
use iroh_relay::{RelayMap, RelayNode};
use n0_future::time::Duration;
@@ -1376,7 +1376,7 @@
}
}
- fn push(&mut self, probe: Probe) -> Result<()> {
+ fn push(&mut self, probe: Probe) -> anyhow::Result<()> {
ensure!(probe.proto() == self.proto, "mismatching probe proto");
self.probes.push(probe);
Ok(())
diff --git a/pr/3161/docs/src/iroh/protocol.rs.html b/pr/3161/docs/src/iroh/protocol.rs.html
index 9d86f827a8..7ddbbe5ec8 100644
--- a/pr/3161/docs/src/iroh/protocol.rs.html
+++ b/pr/3161/docs/src/iroh/protocol.rs.html
@@ -502,8 +502,7 @@
501
502
503
-504
-505
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
+504
//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
//!
//! ## Example
//!
@@ -544,7 +543,6 @@
//! ```
use std::{collections::BTreeMap, sync::Arc};
-use anyhow::Result;
use iroh_base::NodeId;
use n0_future::{
boxed::BoxFuture,
@@ -620,7 +618,7 @@
/// Optional interception point to handle the `Connecting` state.
///
/// This enables accepting 0-RTT data from clients, among other things.
- fn on_connecting(&self, connecting: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, connecting: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
Box::pin(async move {
let conn = connecting.await?;
Ok(conn)
@@ -630,7 +628,7 @@
/// Handle an incoming connection.
///
/// This runs on a freshly spawned tokio task so this can be long-running.
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>>;
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>>;
/// Called when the node shuts down.
fn shutdown(&self) -> BoxFuture<()> {
@@ -639,11 +637,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Arc<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -653,11 +651,11 @@
}
impl<T: ProtocolHandler> ProtocolHandler for Box<T> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.as_ref().on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
self.as_ref().accept(conn)
}
@@ -720,7 +718,7 @@
///
/// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate
/// that panic into the result here.
- pub async fn shutdown(&self) -> Result<()> {
+ pub async fn shutdown(&self) -> anyhow::Result<()> {
if self.is_shutdown() {
return Ok(());
}
@@ -760,7 +758,7 @@
}
/// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`].
- pub async fn spawn(self) -> Result<Router> {
+ pub async fn spawn(self) -> anyhow::Result<Router> {
// Update the endpoint with our alpns.
let alpns = self
.protocols
@@ -916,11 +914,11 @@
}
impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> {
- fn on_connecting(&self, conn: Connecting) -> BoxFuture<Result<Connection>> {
+ fn on_connecting(&self, conn: Connecting) -> BoxFuture<anyhow::Result<Connection>> {
self.proto.on_connecting(conn)
}
- fn accept(&self, conn: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, conn: Connection) -> BoxFuture<anyhow::Result<()>> {
let this = self.clone();
Box::pin(async move {
let remote = conn.remote_node_id()?;
@@ -944,7 +942,7 @@
use super::*;
#[tokio::test]
- async fn test_shutdown() -> Result<()> {
+ async fn test_shutdown() -> anyhow::Result<()> {
let endpoint = Endpoint::builder().bind().await?;
let router = Router::builder(endpoint.clone()).spawn().await?;
@@ -966,7 +964,7 @@
const ECHO_ALPN: &[u8] = b"/iroh/echo/1";
impl ProtocolHandler for Echo {
- fn accept(&self, connection: Connection) -> BoxFuture<Result<()>> {
+ fn accept(&self, connection: Connection) -> BoxFuture<anyhow::Result<()>> {
println!("accepting echo");
Box::pin(async move {
let (mut send, mut recv) = connection.accept_bi().await?;
@@ -982,7 +980,7 @@
}
}
#[tokio::test]
- async fn test_limiter() -> Result<()> {
+ async fn test_limiter() -> anyhow::Result<()> {
let e1 = Endpoint::builder().bind().await?;
// deny all access
let proto = AccessLimit::new(Echo, |_node_id| false);