diff --git a/pr/3355/docs/iroh/protocol/index.html b/pr/3355/docs/iroh/protocol/index.html index 2bdec80e08..b54f6fb77f 100644 --- a/pr/3355/docs/iroh/protocol/index.html +++ b/pr/3355/docs/iroh/protocol/index.html @@ -1,4 +1,4 @@ -iroh::protocol - Rust

Module protocol

Source
Expand description

Tools for spawning an accept loop that routes incoming requests to the right protocol.

+iroh::protocol - Rust

Module protocol

Source
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/3355/docs/iroh/protocol/struct.AccessLimit.html b/pr/3355/docs/iroh/protocol/struct.AccessLimit.html
index 3194955ddd..1a6f10ee25 100644
--- a/pr/3355/docs/iroh/protocol/struct.AccessLimit.html
+++ b/pr/3355/docs/iroh/protocol/struct.AccessLimit.html
@@ -1,15 +1,15 @@
-AccessLimit in iroh::protocol - Rust

Struct AccessLimit

Source
pub struct AccessLimit<P: ProtocolHandler + Clone> { /* private fields */ }
Expand description

Wraps an existing protocol, limiting its access, +AccessLimit in iroh::protocol - Rust

Struct AccessLimit

Source
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>

Source

pub fn new<F>(proto: P, limiter: F) -> Self
where +

Implementations§

Source§

impl<P: ProtocolHandler + Clone> AccessLimit<P>

Source

pub fn new<F>(proto: P, limiter: F) -> Self
where F: Fn(NodeId) -> bool + Send + Sync + 'static,

Create a new AccessLimit.

The function should return true for nodes that are allowed to connect, and false otherwise.

-

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 more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P> Debug for AccessLimit<P>
where - P: Debug + ProtocolHandler + Clone,

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>

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 more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P> Debug for AccessLimit<P>
where + P: Debug + ProtocolHandler + Clone,

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>

Source§

fn on_connecting( &self, conn: Connecting, -) -> impl Future<Output = Result<Connection, AcceptError>> + Send

Optional interception point to handle the Connecting state. Read more
Source§

async fn accept(&self, conn: Connection) -> Result<(), AcceptError>

Handle an incoming connection. Read more
Source§

fn shutdown(&self) -> impl Future<Output = ()> + Send

Called when the router shuts down. Read more

Auto Trait Implementations§

§

impl<P> Freeze for AccessLimit<P>
where +) -> impl Future<Output = Result<Connection, AcceptError>> + Send

Optional interception point to handle the Connecting state. Read more
Source§

async fn accept(&self, conn: Connection) -> Result<(), AcceptError>

Handle an incoming connection. Read more
Source§

fn shutdown(&self) -> impl Future<Output = ()> + Send

Called when the router shuts down. Read more

Auto 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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where diff --git a/pr/3355/docs/iroh/protocol/struct.Router.html b/pr/3355/docs/iroh/protocol/struct.Router.html index 6dd7404731..a3af7f766d 100644 --- a/pr/3355/docs/iroh/protocol/struct.Router.html +++ b/pr/3355/docs/iroh/protocol/struct.Router.html @@ -15,10 +15,10 @@ wait for [tokio::signal::ctrl_c()]:

// wait until the user wants to tokio::signal::ctrl_c().await.context("ctrl+c")?; router.shutdown().await.context("shutdown")?;
-

Implementations§

Source§

impl Router

Source

pub fn builder(endpoint: Endpoint) -> RouterBuilder

Creates a new Router using given Endpoint.

-
Source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint stored in this router.

-
Source

pub fn is_shutdown(&self) -> bool

Checks if the router is already shutdown.

-
Source

pub async fn accept( +

Implementations§

Source§

impl Router

Source

pub fn builder(endpoint: Endpoint) -> RouterBuilder

Creates a new Router using given Endpoint.

+
Source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint stored in this router.

+
Source

pub fn is_shutdown(&self) -> bool

Checks if the router is already shutdown.

+
Source

pub async fn accept( &self, alpn: impl AsRef<[u8]>, handler: impl ProtocolHandler, @@ -28,13 +28,13 @@ with this alpn.

Once the function yields, new connections with this alpn will be handled.

If a protocol handler was already registered for alpn, the previous handler will be shutdown.

Returns true if

-

Source

pub async fn stop_accepting( +

Source

pub async fn stop_accepting( &self, alpn: impl AsRef<[u8]>, ) -> Result<(), StopAcceptingError>

Stops accepting a protocol.

Note that this has only an effect on new connections. Existing connections that were accepted with alpn won’t be closed when calling Router::stop_accepting.

-
Source

pub async fn shutdown(&self) -> Result<(), JoinError>

Shuts down the accept loop cleanly.

+
Source

pub async fn shutdown(&self) -> Result<(), JoinError>

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.

diff --git a/pr/3355/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3355/docs/iroh/protocol/struct.RouterBuilder.html index eec35a8541..14d81340eb 100644 --- a/pr/3355/docs/iroh/protocol/struct.RouterBuilder.html +++ b/pr/3355/docs/iroh/protocol/struct.RouterBuilder.html @@ -1,13 +1,13 @@ RouterBuilder in iroh::protocol - Rust

Struct RouterBuilder

Source
pub struct RouterBuilder { /* private fields */ }
Expand description

Builder for creating a Router for accepting protocols.

-

Implementations§

Source§

impl RouterBuilder

Source

pub fn new(endpoint: Endpoint) -> Self

Creates a new router builder using given Endpoint.

-
Source

pub fn accept( +

Implementations§

Source§

impl RouterBuilder

Source

pub fn new(endpoint: Endpoint) -> Self

Creates a new router builder using given Endpoint.

+
Source

pub fn accept( self, alpn: impl AsRef<[u8]>, handler: impl ProtocolHandler, ) -> Self

Configures the router to accept the ProtocolHandler when receiving a connection with this alpn.

-
Source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint of the node.

-
Source

pub fn spawn(self) -> Router

Spawns an accept loop and returns a handle to it encapsulated as the Router.

+
Source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint of the node.

+
Source

pub fn spawn(self) -> Router

Spawns an accept loop and returns a handle to it encapsulated as the Router.

Trait Implementations§

Source§

impl Debug for RouterBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where diff --git a/pr/3355/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3355/docs/iroh/protocol/trait.ProtocolHandler.html index d133f07728..1d99f398f2 100644 --- a/pr/3355/docs/iroh/protocol/trait.ProtocolHandler.html +++ b/pr/3355/docs/iroh/protocol/trait.ProtocolHandler.html @@ -47,4 +47,4 @@ the router closes the endpoint.

) -> Result<Connection, AcceptError>

Source§

async fn accept(&self, conn: Connection) -> Result<(), AcceptError>

Source§

async fn shutdown(&self)

Source§

impl<T: ProtocolHandler> ProtocolHandler for Arc<T>

Source§

async fn on_connecting( &self, conn: Connecting, -) -> Result<Connection, AcceptError>

Source§

async fn accept(&self, conn: Connection) -> Result<(), AcceptError>

Source§

async fn shutdown(&self)

Implementors§

\ No newline at end of file +) -> Result<Connection, AcceptError>
Source§

async fn accept(&self, conn: Connection) -> Result<(), AcceptError>

Source§

async fn shutdown(&self)

Implementors§

Source§

impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P>

\ No newline at end of file diff --git a/pr/3355/docs/iroh_relay/client/enum.ReceivedMessage.html b/pr/3355/docs/iroh_relay/client/enum.ReceivedMessage.html index 4f2e1b3f73..7c862d05b7 100644 --- a/pr/3355/docs/iroh_relay/client/enum.ReceivedMessage.html +++ b/pr/3355/docs/iroh_relay/client/enum.ReceivedMessage.html @@ -1,9 +1,9 @@ ReceivedMessage in iroh_relay::client - Rust

Enum ReceivedMessage

Source
pub enum ReceivedMessage {
     ReceivedPacket {
-        remote_node_id: NodeId,
+        remote_node_id: NodeId,
         data: Bytes,
     },
-    NodeGone(NodeId),
+    NodeGone(NodeId),
     Ping([u8; 8]),
     Pong([u8; 8]),
     KeepAlive,
@@ -17,9 +17,9 @@
 }
Expand description

The messages received from a framed relay stream.

This is a type-validated version of the Frames on the RelayCodec.

Variants§

§

ReceivedPacket

Represents an incoming packet.

-

Fields

§remote_node_id: NodeId

The [NodeId] of the packet sender.

+

Fields

§remote_node_id: NodeId

The NodeId of the packet sender.

§data: Bytes

The received packet bytes.

-
§

NodeGone(NodeId)

Indicates that the client identified by the underlying public key had previously sent you a +

§

NodeGone(NodeId)

Indicates that the client identified by the underlying public key had previously sent you a packet but has now disconnected from the server.

§

Ping([u8; 8])

Request from a client or server to reply to the other side with a ReceivedMessage::Pong with the given payload.

diff --git a/pr/3355/docs/iroh_relay/client/enum.SendMessage.html b/pr/3355/docs/iroh_relay/client/enum.SendMessage.html index 6a3c982bf5..e07368647b 100644 --- a/pr/3355/docs/iroh_relay/client/enum.SendMessage.html +++ b/pr/3355/docs/iroh_relay/client/enum.SendMessage.html @@ -1,9 +1,9 @@ SendMessage in iroh_relay::client - Rust

Enum SendMessage

Source
pub enum SendMessage {
-    SendPacket(NodeId, Bytes),
+    SendPacket(NodeId, Bytes),
     Ping([u8; 8]),
     Pong([u8; 8]),
 }
Expand description

Messages we can send to a relay server.

-

Variants§

§

SendPacket(NodeId, Bytes)

Send a packet of data to the [NodeId].

+

Variants§

§

SendPacket(NodeId, Bytes)

Send a packet of data to the NodeId.

§

Ping([u8; 8])

Sends a ping message to the connected relay server.

§

Pong([u8; 8])

Sends a pong message to the connected relay server.

Trait Implementations§

Source§

impl Debug for SendMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Sink<SendMessage> for Client

Source§

type Error = SendError

The type of value produced by the sink when an error occurs.
Source§

fn poll_ready( diff --git a/pr/3355/docs/iroh_relay/client/struct.ClientBuilder.html b/pr/3355/docs/iroh_relay/client/struct.ClientBuilder.html index 53e281c526..6e63827fbb 100644 --- a/pr/3355/docs/iroh_relay/client/struct.ClientBuilder.html +++ b/pr/3355/docs/iroh_relay/client/struct.ClientBuilder.html @@ -1,7 +1,7 @@ ClientBuilder in iroh_relay::client - Rust

Struct ClientBuilder

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

Build a Client.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new( - url: impl Into<RelayUrl>, - secret_key: SecretKey, + url: impl Into<RelayUrl>, + secret_key: SecretKey, dns_resolver: DnsResolver, ) -> Self

Create a new ClientBuilder

Source

pub fn protocol(self, protocol: Protocol) -> Self

Sets whether to connect to the relay via websockets or not. diff --git a/pr/3355/docs/iroh_relay/dns/struct.DnsResolver.html b/pr/3355/docs/iroh_relay/dns/struct.DnsResolver.html index c3244e1e54..a679e39d46 100644 --- a/pr/3355/docs/iroh_relay/dns/struct.DnsResolver.html +++ b/pr/3355/docs/iroh_relay/dns/struct.DnsResolver.html @@ -67,9 +67,9 @@ at T+0ms, T+200ms and T+300ms. The timeout is applied as stated in summary of all errors otherwise.

Source

pub async fn lookup_node_by_id( &self, - node_id: &NodeId, + node_id: &NodeId, origin: &str, -) -> Result<NodeInfo, LookupError>

Looks up node info by [NodeId] and origin domain name.

+) -> Result<NodeInfo, LookupError>

Looks up node info by NodeId and origin domain name.

To lookup nodes that published their node info to the DNS servers run by n0, pass N0_DNS_NODE_ORIGIN_PROD as origin.

Source

pub async fn lookup_node_by_domain_name( @@ -87,10 +87,10 @@ at T+0ms, T+200ms and T+300ms. The result of the first successful call is return summary of all errors otherwise.

Source

pub async fn lookup_node_by_id_staggered( &self, - node_id: &NodeId, + node_id: &NodeId, origin: &str, delays_ms: &[u64], -) -> Result<NodeInfo, StaggeredError<LookupError>>

Looks up node info by [NodeId] and origin domain name.

+) -> Result<NodeInfo, StaggeredError<LookupError>>

Looks up node info by NodeId and origin domain name.

From the moment this function is called, each lookup is scheduled after the delays in delays_ms with the first call being done immediately. [200ms, 300ms] results in calls at T+0ms, T+200ms and T+300ms. The result of the first successful call is returned, or a diff --git a/pr/3355/docs/iroh_relay/index.html b/pr/3355/docs/iroh_relay/index.html index a4c2940432..5b1f8aca6e 100644 --- a/pr/3355/docs/iroh_relay/index.html +++ b/pr/3355/docs/iroh_relay/index.html @@ -25,6 +25,6 @@ Tailscale.

STUN support and expose metrics.

-

Re-exports§

pub use protos::relay::MAX_PACKET_SIZE;

Modules§

client
Exposes Client, which allows to establish connections to a relay server.
defaults
Default values used in the relay.
dnsNon-wasm_browser
DNS resolver
http
HTTP-specific constants for the relay server and client.
node_info
Support for handling DNS resource records for dialing by [NodeId].
protos
Protocols used by the iroh-relay
quic
Create a QUIC server that accepts connections +

Re-exports§

pub use protos::relay::MAX_PACKET_SIZE;

Modules§

client
Exposes Client, which allows to establish connections to a relay server.
defaults
Default values used in the relay.
dnsNon-wasm_browser
DNS resolver
http
HTTP-specific constants for the relay server and client.
node_info
Support for handling DNS resource records for dialing by NodeId.
protos
Protocols used by the iroh-relay
quic
Create a QUIC server that accepts connections for QUIC address discovery.
serverserver
A fully-fledged iroh-relay server over HTTP or HTTPS.

Structs§

PingTracker
Tracks pings on a single relay connection.
RelayMap
Configuration of all the relay servers that can be used.
RelayNode
Information on a specific relay server.
RelayQuicConfig
Configuration for speaking to the QUIC endpoint on the relay server to do QUIC address discovery.
\ No newline at end of file diff --git a/pr/3355/docs/iroh_relay/node_info/index.html b/pr/3355/docs/iroh_relay/node_info/index.html index 00c61b2d49..7c44a3876d 100644 --- a/pr/3355/docs/iroh_relay/node_info/index.html +++ b/pr/3355/docs/iroh_relay/node_info/index.html @@ -1,5 +1,5 @@ -iroh_relay::node_info - Rust

Module node_info

Source
Expand description

Support for handling DNS resource records for dialing by [NodeId].

-

Dialing by [NodeId] is supported by iroh nodes publishing Pkarr records to DNS +iroh_relay::node_info - Rust

Module node_info

Source
Expand description

Support for handling DNS resource records for dialing by NodeId.

+

Dialing by NodeId is supported by iroh nodes publishing Pkarr records to DNS servers or the Mainline DHT. This module supports creating and parsing these records.

DNS records are published under the following names:

_iroh.<z32-node-id>.<origin-domain> TXT

@@ -8,7 +8,7 @@ servers or the Mainline DHT. This module supports creating and parsing these re

_iroh is the record name as defined by IROH_TXT_NAME.

  • -

    <z32-node-id> is the z-base-32 encoding of the [NodeId].

    +

    <z32-node-id> is the z-base-32 encoding of the NodeId.

  • <origin-domain> is the domain name of the publishing DNS server, @@ -23,12 +23,12 @@ servers or the Mainline DHT. This module supports creating and parsing these re in RFC1464. The following attributes are defined:

    • -

      relay=<url>: The home RelayUrl of this node.

      +

      relay=<url>: The home RelayUrl of this node.

    • addr=<addr> <addr>: A space-separated list of sockets addresses for this iroh node. Each address is an IPv4 or IPv6 address with a port.

    -
  • Structs§

    MaxLengthExceededError
    Error returned when an input value is too long for UserData.
    NodeData
    Data about a node that may be published to and resolved from discovery services.
    NodeInfo
    Information about a node that may be published to and resolved from discovery services.
    UserData
    Under the hood this is a UTF-8 String is no longer than UserData::MAX_LENGTH bytes.

    Enums§

    DecodingError
    EncodingError
    LookupErrorNon-wasm_browser
    ParseError

    Constants§

    IROH_TXT_NAME
    The DNS name for the iroh TXT record.

    Traits§

    NodeIdExt
    Extension methods for [NodeId] to encode to and decode from [z32], +

    Structs§

    MaxLengthExceededError
    Error returned when an input value is too long for UserData.
    NodeData
    Data about a node that may be published to and resolved from discovery services.
    NodeInfo
    Information about a node that may be published to and resolved from discovery services.
    UserData
    Under the hood this is a UTF-8 String is no longer than UserData::MAX_LENGTH bytes.

    Enums§

    DecodingError
    EncodingError
    LookupErrorNon-wasm_browser
    ParseError

    Constants§

    IROH_TXT_NAME
    The DNS name for the iroh TXT record.

    Traits§

    NodeIdExt
    Extension methods for NodeId to encode to and decode from [z32], which is the encoding used in [pkarr] domain names.
    \ No newline at end of file diff --git a/pr/3355/docs/iroh_relay/node_info/struct.NodeData.html b/pr/3355/docs/iroh_relay/node_info/struct.NodeData.html index 8315d3cd78..238c3986d7 100644 --- a/pr/3355/docs/iroh_relay/node_info/struct.NodeData.html +++ b/pr/3355/docs/iroh_relay/node_info/struct.NodeData.html @@ -1,20 +1,20 @@ NodeData in iroh_relay::node_info - Rust

    Struct NodeData

    Source
    pub struct NodeData { /* private fields */ }
    Expand description

    Data about a node that may be published to and resolved from discovery services.

    -

    This includes an optional [RelayUrl], a set of direct addresses, and the optional +

    This includes an optional RelayUrl, a set of direct addresses, and the optional UserData, a string that can be set by applications and is not parsed or used by iroh itself.

    -

    This struct does not include the node’s [NodeId], only the data about a certain -node. See NodeInfo for a struct that contains a [NodeId] with associated NodeData.

    +

    This struct does not include the node’s NodeId, only the data about a certain +node. See NodeInfo for a struct that contains a NodeId with associated NodeData.

    Implementations§

    Source§

    impl NodeData

    Source

    pub fn new( - relay_url: Option<RelayUrl>, + relay_url: Option<RelayUrl>, direct_addresses: BTreeSet<SocketAddr>, ) -> Self

    Creates a new NodeData with a relay URL and a set of direct addresses.

    -
    Source

    pub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self

    Sets the relay URL and returns the updated node data.

    +
    Source

    pub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self

    Sets the relay URL and returns the updated node data.

    Source

    pub fn with_direct_addresses( self, direct_addresses: BTreeSet<SocketAddr>, ) -> Self

    Sets the direct addresses and returns the updated node data.

    Source

    pub fn with_user_data(self, user_data: Option<UserData>) -> Self

    Sets the user-defined data and returns the updated node data.

    -
    Source

    pub fn relay_url(&self) -> Option<&RelayUrl>

    Returns the relay URL of the node.

    +
    Source

    pub fn relay_url(&self) -> Option<&RelayUrl>

    Returns the relay URL of the node.

    Source

    pub fn user_data(&self) -> Option<&UserData>

    Returns the optional user-defined data of the node.

    Source

    pub fn direct_addresses(&self) -> &BTreeSet<SocketAddr>

    Returns the direct addresses of the node.

    Source

    pub fn clear_direct_addresses(&mut self)

    Removes all direct addresses from the node data.

    @@ -22,9 +22,9 @@ node. See IntoIterator<Item = SocketAddr>, )

    Adds direct addresses to the node data.

    -
    Source

    pub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)

    Sets the relay URL of the node data.

    +
    Source

    pub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)

    Sets the relay URL of the node data.

    Source

    pub fn set_user_data(&mut self, user_data: Option<UserData>)

    Sets the user-defined data of the node data.

    -

    Trait Implementations§

    Source§

    impl Clone for NodeData

    Source§

    fn clone(&self) -> NodeData

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for NodeData

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Default for NodeData

    Source§

    fn default() -> NodeData

    Returns the “default value” for a type. Read more
    Source§

    impl From<NodeAddr> for NodeData

    Source§

    fn from(node_addr: NodeAddr) -> Self

    Converts to this type from the input type.
    Source§

    impl PartialEq for NodeData

    Source§

    fn eq(&self, other: &NodeData) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, +

    Trait Implementations§

    Source§

    impl Clone for NodeData

    Source§

    fn clone(&self) -> NodeData

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for NodeData

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Default for NodeData

    Source§

    fn default() -> NodeData

    Returns the “default value” for a type. Read more
    Source§

    impl From<NodeAddr> for NodeData

    Source§

    fn from(node_addr: NodeAddr) -> Self

    Converts to this type from the input type.
    Source§

    impl PartialEq for NodeData

    Source§

    fn eq(&self, other: &NodeData) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
    Source§

    impl Eq for NodeData

    Source§

    impl StructuralPartialEq for NodeData

    Auto Trait Implementations§

    §

    impl Freeze for NodeData

    §

    impl RefUnwindSafe for NodeData

    §

    impl Send for NodeData

    §

    impl Sync for NodeData

    §

    impl Unpin for NodeData

    §

    impl UnwindSafe for NodeData

    Blanket Implementations§

    Source§

    impl<T> Any for T
    where T: 'static + ?Sized,

    Source§

    fn type_id(&self) -> TypeId

    Gets the TypeId of self. Read more
    §

    impl<'a, T, E> AsTaggedExplicit<'a, E> for T
    where T: 'a,

    §

    fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

    §

    impl<'a, T, E> AsTaggedImplicit<'a, E> for T
    where diff --git a/pr/3355/docs/iroh_relay/node_info/struct.NodeInfo.html b/pr/3355/docs/iroh_relay/node_info/struct.NodeInfo.html index 3009617365..62193891d4 100644 --- a/pr/3355/docs/iroh_relay/node_info/struct.NodeInfo.html +++ b/pr/3355/docs/iroh_relay/node_info/struct.NodeInfo.html @@ -1,32 +1,32 @@ NodeInfo in iroh_relay::node_info - Rust

    Struct NodeInfo

    Source
    pub struct NodeInfo {
    -    pub node_id: NodeId,
    +    pub node_id: NodeId,
         pub data: NodeData,
     }
    Expand description

    Information about a node that may be published to and resolved from discovery services.

    -

    This struct couples a [NodeId] with its associated NodeData.

    -

    Fields§

    §node_id: NodeId

    The [NodeId] of the node this is about.

    +

    This struct couples a NodeId with its associated NodeData.

    +

    Fields§

    §node_id: NodeId

    The NodeId of the node this is about.

    §data: NodeData

    The information published about the node.

    -

    Implementations§

    Source§

    impl NodeInfo

    Source

    pub fn new(node_id: NodeId) -> Self

    Creates a new NodeInfo with an empty NodeData.

    -
    Source

    pub fn from_parts(node_id: NodeId, data: NodeData) -> Self

    Creates a new NodeInfo from its parts.

    -
    Source

    pub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self

    Sets the relay URL and returns the updated node info.

    +

    Implementations§

    Source§

    impl NodeInfo

    Source

    pub fn new(node_id: NodeId) -> Self

    Creates a new NodeInfo with an empty NodeData.

    +
    Source

    pub fn from_parts(node_id: NodeId, data: NodeData) -> Self

    Creates a new NodeInfo from its parts.

    +
    Source

    pub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self

    Sets the relay URL and returns the updated node info.

    Source

    pub fn with_direct_addresses( self, direct_addresses: BTreeSet<SocketAddr>, ) -> Self

    Sets the direct addresses and returns the updated node info.

    Source

    pub fn with_user_data(self, user_data: Option<UserData>) -> Self

    Sets the user-defined data and returns the updated node info.

    -
    Source

    pub fn to_node_addr(&self) -> NodeAddr

    Converts into a [NodeAddr] by cloning the needed fields.

    -
    Source

    pub fn into_node_addr(self) -> NodeAddr

    Converts into a [NodeAddr] without cloning.

    +
    Source

    pub fn to_node_addr(&self) -> NodeAddr

    Converts into a NodeAddr by cloning the needed fields.

    +
    Source

    pub fn into_node_addr(self) -> NodeAddr

    Converts into a NodeAddr without cloning.

    Source

    pub fn from_txt_lookup(lookup: TxtLookup) -> Result<Self, ParseError>

    Available on non-wasm_browser only.

    Parses a NodeInfo from a TXT records lookup.

    Source

    pub fn from_pkarr_signed_packet( packet: &SignedPacket, ) -> Result<Self, ParseError>

    Parses a NodeInfo from a [pkarr::SignedPacket].

    Source

    pub fn to_pkarr_signed_packet( &self, - secret_key: &SecretKey, + secret_key: &SecretKey, ttl: u32, ) -> Result<SignedPacket, EncodingError>

    Creates a [pkarr::SignedPacket].

    -

    This constructs a DNS packet and signs it with a [SecretKey].

    +

    This constructs a DNS packet and signs it with a SecretKey.

    Source

    pub fn to_txt_strings(&self) -> Vec<String>

    Converts into a list of {key}={value} strings.

    -

    Methods from Deref<Target = NodeData>§

    Source

    pub fn relay_url(&self) -> Option<&RelayUrl>

    Returns the relay URL of the node.

    +

    Methods from Deref<Target = NodeData>§

    Source

    pub fn relay_url(&self) -> Option<&RelayUrl>

    Returns the relay URL of the node.

    Source

    pub fn user_data(&self) -> Option<&UserData>

    Returns the optional user-defined data of the node.

    Source

    pub fn direct_addresses(&self) -> &BTreeSet<SocketAddr>

    Returns the direct addresses of the node.

    Source

    pub fn clear_direct_addresses(&mut self)

    Removes all direct addresses from the node data.

    @@ -34,9 +34,9 @@ &mut self, addrs: impl IntoIterator<Item = SocketAddr>, )

    Adds direct addresses to the node data.

    -
    Source

    pub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)

    Sets the relay URL of the node data.

    +
    Source

    pub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)

    Sets the relay URL of the node data.

    Source

    pub fn set_user_data(&mut self, user_data: Option<UserData>)

    Sets the user-defined data of the node data.

    -

    Trait Implementations§

    Source§

    impl Clone for NodeInfo

    Source§

    fn clone(&self) -> NodeInfo

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for NodeInfo

    Source§

    fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Deref for NodeInfo

    Source§

    type Target = NodeData

    The resulting type after dereferencing.
    Source§

    fn deref(&self) -> &Self::Target

    Dereferences the value.
    Source§

    impl DerefMut for NodeInfo

    Source§

    fn deref_mut(&mut self) -> &mut Self::Target

    Mutably dereferences the value.
    Source§

    impl From<NodeAddr> for NodeInfo

    Source§

    fn from(addr: NodeAddr) -> Self

    Converts to this type from the input type.
    Source§

    impl From<NodeInfo> for NodeAddr

    Source§

    fn from(value: NodeInfo) -> Self

    Converts to this type from the input type.
    Source§

    impl PartialEq for NodeInfo

    Source§

    fn eq(&self, other: &NodeInfo) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, +

    Trait Implementations§

    Source§

    impl Clone for NodeInfo

    Source§

    fn clone(&self) -> NodeInfo

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for NodeInfo

    Source§

    fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Deref for NodeInfo

    Source§

    type Target = NodeData

    The resulting type after dereferencing.
    Source§

    fn deref(&self) -> &Self::Target

    Dereferences the value.
    Source§

    impl DerefMut for NodeInfo

    Source§

    fn deref_mut(&mut self) -> &mut Self::Target

    Mutably dereferences the value.
    Source§

    impl From<NodeAddr> for NodeInfo

    Source§

    fn from(addr: NodeAddr) -> Self

    Converts to this type from the input type.
    Source§

    impl From<NodeInfo> for NodeAddr

    Source§

    fn from(value: NodeInfo) -> Self

    Converts to this type from the input type.
    Source§

    impl PartialEq for NodeInfo

    Source§

    fn eq(&self, other: &NodeInfo) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
    Source§

    impl Eq for NodeInfo

    Source§

    impl StructuralPartialEq for NodeInfo

    Auto Trait Implementations§

    Blanket Implementations§

    Source§

    impl<T> Any for T
    where T: 'static + ?Sized,

    Source§

    fn type_id(&self) -> TypeId

    Gets the TypeId of self. Read more
    §

    impl<'a, T, E> AsTaggedExplicit<'a, E> for T
    where T: 'a,

    §

    fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

    §

    impl<'a, T, E> AsTaggedImplicit<'a, E> for T
    where diff --git a/pr/3355/docs/iroh_relay/node_info/trait.NodeIdExt.html b/pr/3355/docs/iroh_relay/node_info/trait.NodeIdExt.html index e60ccd0737..19265ef095 100644 --- a/pr/3355/docs/iroh_relay/node_info/trait.NodeIdExt.html +++ b/pr/3355/docs/iroh_relay/node_info/trait.NodeIdExt.html @@ -1,9 +1,9 @@ NodeIdExt in iroh_relay::node_info - Rust

    Trait NodeIdExt

    Source
    pub trait NodeIdExt {
         // Required methods
         fn to_z32(&self) -> String;
    -    fn from_z32(s: &str) -> Result<NodeId, DecodingError>;
    -}
    Expand description

    Extension methods for [NodeId] to encode to and decode from [z32], + fn from_z32(s: &str) -> Result<NodeId, DecodingError>; +}

    Expand description

    Extension methods for NodeId to encode to and decode from [z32], which is the encoding used in [pkarr] domain names.

    -

    Required Methods§

    Source

    fn to_z32(&self) -> String

    Encodes a [NodeId] in [z-base-32] encoding.

    -
    Source

    fn from_z32(s: &str) -> Result<NodeId, DecodingError>

    Parses a [NodeId] from [z-base-32] encoding.

    -

    Dyn Compatibility§

    This trait is not dyn compatible.

    In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

    Implementations on Foreign Types§

    Source§

    impl NodeIdExt for NodeId

    Implementors§

    \ No newline at end of file +

    Required Methods§

    Source

    fn to_z32(&self) -> String

    Encodes a NodeId in [z-base-32] encoding.

    +
    Source

    fn from_z32(s: &str) -> Result<NodeId, DecodingError>

    Parses a NodeId from [z-base-32] encoding.

    +

    Dyn Compatibility§

    This trait is not dyn compatible.

    In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

    Implementations on Foreign Types§

    Source§

    impl NodeIdExt for NodeId

    Implementors§

    \ No newline at end of file diff --git a/pr/3355/docs/iroh_relay/server/enum.AccessConfig.html b/pr/3355/docs/iroh_relay/server/enum.AccessConfig.html index bb46abbe03..d23a81bd37 100644 --- a/pr/3355/docs/iroh_relay/server/enum.AccessConfig.html +++ b/pr/3355/docs/iroh_relay/server/enum.AccessConfig.html @@ -1,10 +1,10 @@ AccessConfig in iroh_relay::server - Rust

    Enum AccessConfig

    Source
    pub enum AccessConfig {
         Everyone,
    -    Restricted(Box<dyn Fn(NodeId) -> Boxed<Access> + Send + Sync + 'static>),
    +    Restricted(Box<dyn Fn(NodeId) -> Boxed<Access> + Send + Sync + 'static>),
     }
    Available on crate feature server only.
    Expand description

    Controls which nodes are allowed to use the relay.

    Variants§

    §

    Everyone

    Everyone

    -
    §

    Restricted(Box<dyn Fn(NodeId) -> Boxed<Access> + Send + Sync + 'static>)

    Only nodes for which the function returns Access::Allow.

    -

    Implementations§

    Source§

    impl AccessConfig

    Source

    pub async fn is_allowed(&self, node: NodeId) -> bool

    Is this node allowed?

    +
    §

    Restricted(Box<dyn Fn(NodeId) -> Boxed<Access> + Send + Sync + 'static>)

    Only nodes for which the function returns Access::Allow.

    +

    Implementations§

    Source§

    impl AccessConfig

    Source

    pub async fn is_allowed(&self, node: NodeId) -> bool

    Is this node allowed?

    Trait Implementations§

    Source§

    impl Debug for AccessConfig

    Source§

    fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more

    Auto Trait Implementations§

    Blanket Implementations§

    Source§

    impl<T> Any for T
    where T: 'static + ?Sized,

    Source§

    fn type_id(&self) -> TypeId

    Gets the TypeId of self. Read more
    §

    impl<'a, T, E> AsTaggedExplicit<'a, E> for T
    where T: 'a,

    §

    fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

    §

    impl<'a, T, E> AsTaggedImplicit<'a, E> for T
    where diff --git a/pr/3355/docs/iroh_relay/server/struct.Server.html b/pr/3355/docs/iroh_relay/server/struct.Server.html index 095b81c3bc..4b30f61650 100644 --- a/pr/3355/docs/iroh_relay/server/struct.Server.html +++ b/pr/3355/docs/iroh_relay/server/struct.Server.html @@ -18,9 +18,9 @@ case there is an error in the server before it is shut down.

    Source

    pub fn quic_addr(&self) -> Option<SocketAddr>

    The socket address the QUIC server is listening on.

    Source

    pub fn stun_addr(&self) -> Option<SocketAddr>

    The socket address the STUN server is listening on.

    Source

    pub fn certificates(&self) -> Option<Vec<CertificateDer<'static>>>

    The certificates chain if configured with manual TLS certificates.

    -
    Source

    pub fn https_url(&self) -> Option<RelayUrl>

    Available on crate feature test-utils only.

    Get the server’s https [RelayUrl].

    +
    Source

    pub fn https_url(&self) -> Option<RelayUrl>

    Available on crate feature test-utils only.

    Get the server’s https RelayUrl.

    This uses Self::https_addr so it’s mostly useful for local development.

    -
    Source

    pub fn http_url(&self) -> Option<RelayUrl>

    Available on crate feature test-utils only.

    Get the server’s http [RelayUrl].

    +
    Source

    pub fn http_url(&self) -> Option<RelayUrl>

    Available on crate feature test-utils only.

    Get the server’s http RelayUrl.

    This uses Self::http_addr so it’s mostly useful for local development.

    Source

    pub fn metrics(&self) -> &RelayMetrics

    Returns the metrics collected in the relay server.

    Trait Implementations§

    Source§

    impl Debug for Server

    Source§

    fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more

    Auto Trait Implementations§

    §

    impl Freeze for Server

    §

    impl RefUnwindSafe for Server

    §

    impl Send for Server

    §

    impl Sync for Server

    §

    impl Unpin for Server

    §

    impl UnwindSafe for Server

    Blanket Implementations§

    Source§

    impl<T> Any for T
    where diff --git a/pr/3355/docs/iroh_relay/struct.RelayMap.html b/pr/3355/docs/iroh_relay/struct.RelayMap.html index 0c33630093..66406bee10 100644 --- a/pr/3355/docs/iroh_relay/struct.RelayMap.html +++ b/pr/3355/docs/iroh_relay/struct.RelayMap.html @@ -1,15 +1,15 @@ RelayMap in iroh_relay - Rust

    Struct RelayMap

    Source
    pub struct RelayMap { /* private fields */ }
    Expand description

    Configuration of all the relay servers that can be used.

    -

    Implementations§

    Source§

    impl RelayMap

    Source

    pub fn urls(&self) -> impl Iterator<Item = &RelayUrl>

    Returns the sorted relay URLs.

    +

    Implementations§

    Source§

    impl RelayMap

    Source

    pub fn urls(&self) -> impl Iterator<Item = &RelayUrl>

    Returns the sorted relay URLs.

    Source

    pub fn empty() -> Self

    Create an empty relay map.

    Source

    pub fn nodes(&self) -> impl Iterator<Item = &Arc<RelayNode>>

    Returns an Iterator over all known nodes.

    -
    Source

    pub fn contains_node(&self, url: &RelayUrl) -> bool

    Is this a known node?

    -
    Source

    pub fn get_node(&self, url: &RelayUrl) -> Option<&Arc<RelayNode>>

    Get the given node.

    +
    Source

    pub fn contains_node(&self, url: &RelayUrl) -> bool

    Is this a known node?

    +
    Source

    pub fn get_node(&self, url: &RelayUrl) -> Option<&Arc<RelayNode>>

    Get the given node.

    Source

    pub fn len(&self) -> usize

    How many nodes are known?

    Source

    pub fn is_empty(&self) -> bool

    Are there any nodes in this map?

    -

    Trait Implementations§

    Source§

    impl Clone for RelayMap

    Source§

    fn clone(&self) -> RelayMap

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for RelayMap

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Display for RelayMap

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl From<RelayNode> for RelayMap

    Source§

    fn from(value: RelayNode) -> Self

    Converts to this type from the input type.
    Source§

    impl From<RelayUrl> for RelayMap

    Source§

    fn from(value: RelayUrl) -> Self

    Creates a RelayMap from a [RelayUrl].

    +

    Trait Implementations§

    Source§

    impl Clone for RelayMap

    Source§

    fn clone(&self) -> RelayMap

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for RelayMap

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl Display for RelayMap

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl From<RelayNode> for RelayMap

    Source§

    fn from(value: RelayNode) -> Self

    Converts to this type from the input type.
    Source§

    impl From<RelayUrl> for RelayMap

    Source§

    fn from(value: RelayUrl) -> Self

    Creates a RelayMap from a RelayUrl.

    The RelayNodes in the RelayMap will have the default STUN and QUIC address discovery ports.

    -
    Source§

    impl FromIterator<RelayNode> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayNode>>(iter: T) -> Self

    Creates a value from an iterator. Read more
    Source§

    impl FromIterator<RelayUrl> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayUrl>>(iter: T) -> Self

    Creates a RelayMap from an iterator of [RelayUrl].

    +
    Source§

    impl FromIterator<RelayNode> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayNode>>(iter: T) -> Self

    Creates a value from an iterator. Read more
    Source§

    impl FromIterator<RelayUrl> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayUrl>>(iter: T) -> Self

    Creates a RelayMap from an iterator of RelayUrl.

    The RelayNodes in the RelayMap will have the default STUN and QUIC address discovery ports.

    Source§

    impl PartialEq for RelayMap

    Source§

    fn eq(&self, other: &RelayMap) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, diff --git a/pr/3355/docs/iroh_relay/struct.RelayNode.html b/pr/3355/docs/iroh_relay/struct.RelayNode.html index 9c9fd26a54..7690812c63 100644 --- a/pr/3355/docs/iroh_relay/struct.RelayNode.html +++ b/pr/3355/docs/iroh_relay/struct.RelayNode.html @@ -1,11 +1,11 @@ RelayNode in iroh_relay - Rust

    Struct RelayNode

    Source
    pub struct RelayNode {
    -    pub url: RelayUrl,
    +    pub url: RelayUrl,
         pub stun_only: bool,
         pub stun_port: u16,
         pub quic: Option<RelayQuicConfig>,
     }
    Expand description

    Information on a specific relay server.

    Includes the Url where it can be dialed.

    -

    Fields§

    §url: RelayUrl

    The [RelayUrl] where this relay server can be dialed.

    +

    Fields§

    §url: RelayUrl

    The RelayUrl where this relay server can be dialed.

    §stun_only: bool

    Whether this relay server should only be used for STUN requests.

    This essentially allows you to use a normal STUN server as a relay node, no relay functionality is used.

    @@ -15,7 +15,7 @@ functionality is used.

    When None, we will not attempt to do QUIC address discovery with this relay server.

    Trait Implementations§

    Source§

    impl Clone for RelayNode

    Source§

    fn clone(&self) -> RelayNode

    Returns a copy of the value. Read more
    1.0.0 · Source§

    fn clone_from(&mut self, source: &Self)

    Performs copy-assignment from source. Read more
    Source§

    impl Debug for RelayNode

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl<'de> Deserialize<'de> for RelayNode

    Source§

    fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
    where - __D: Deserializer<'de>,

    Deserialize this value from the given Serde deserializer. Read more
    Source§

    impl Display for RelayNode

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl From<RelayNode> for RelayMap

    Source§

    fn from(value: RelayNode) -> Self

    Converts to this type from the input type.
    Source§

    impl From<RelayUrl> for RelayNode

    Source§

    fn from(value: RelayUrl) -> Self

    Converts to this type from the input type.
    Source§

    impl FromIterator<RelayNode> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayNode>>(iter: T) -> Self

    Creates a value from an iterator. Read more
    Source§

    impl Ord for RelayNode

    Source§

    fn cmp(&self, other: &RelayNode) -> Ordering

    This method returns an Ordering between self and other. Read more
    1.21.0 · Source§

    fn max(self, other: Self) -> Self
    where + __D: Deserializer<'de>,

    Deserialize this value from the given Serde deserializer. Read more
    Source§

    impl Display for RelayNode

    Source§

    fn fmt(&self, f: &mut Formatter<'_>) -> Result

    Formats the value using the given formatter. Read more
    Source§

    impl From<RelayNode> for RelayMap

    Source§

    fn from(value: RelayNode) -> Self

    Converts to this type from the input type.
    Source§

    impl From<RelayUrl> for RelayNode

    Source§

    fn from(value: RelayUrl) -> Self

    Converts to this type from the input type.
    Source§

    impl FromIterator<RelayNode> for RelayMap

    Source§

    fn from_iter<T: IntoIterator<Item = RelayNode>>(iter: T) -> Self

    Creates a value from an iterator. Read more
    Source§

    impl Ord for RelayNode

    Source§

    fn cmp(&self, other: &RelayNode) -> Ordering

    This method returns an Ordering between self and other. Read more
    1.21.0 · Source§

    fn max(self, other: Self) -> Self
    where Self: Sized,

    Compares and returns the maximum of two values. Read more
    1.21.0 · Source§

    fn min(self, other: Self) -> Self
    where Self: Sized,

    Compares and returns the minimum of two values. Read more
    1.50.0 · Source§

    fn clamp(self, min: Self, max: Self) -> Self
    where Self: Sized,

    Restrict a value to a certain interval. Read more
    Source§

    impl PartialEq for RelayNode

    Source§

    fn eq(&self, other: &RelayNode) -> bool

    Tests for self and other values to be equal, and is used by ==.
    1.0.0 · Source§

    fn ne(&self, other: &Rhs) -> bool

    Tests for !=. The default implementation is almost always sufficient, diff --git a/pr/3355/docs/src/iroh/protocol.rs.html b/pr/3355/docs/src/iroh/protocol.rs.html index 9e181e874d..ecf05076c2 100644 --- a/pr/3355/docs/src/iroh/protocol.rs.html +++ b/pr/3355/docs/src/iroh/protocol.rs.html @@ -43,7 +43,7 @@ 43use snafu::{Backtrace, Snafu}; 44use tokio::sync::{mpsc, oneshot, Mutex}; 45use tokio_util::sync::CancellationToken; -46use tracing::{error, info_span, trace, warn, Instrument}; +46use tracing::{debug, error, info_span, trace, warn, Instrument}; 47 48use crate::{ 49 endpoint::{Connecting, Connection, RemoteNodeIdError}, @@ -310,602 +310,607 @@ 310 } 311} 312 -313async fn shutdown_timeout(handler: Arc<dyn DynProtocolHandler>) -> Option<()> { -314 time::timeout(SHUTDOWN_TIMEOUT, handler.shutdown()) -315 .await -316 .ok() -317} -318 -319/// A typed map of protocol handlers, mapping them from ALPNs. -320#[derive(Debug, Default)] -321pub(crate) struct ProtocolMap(std::sync::RwLock<BTreeMap<Vec<u8>, Arc<dyn DynProtocolHandler>>>); -322 -323impl ProtocolMap { -324 /// Returns the registered protocol handler for an ALPN as a [`Arc<dyn ProtocolHandler>`]. -325 pub(crate) fn get(&self, alpn: &[u8]) -> Option<Arc<dyn DynProtocolHandler>> { -326 self.0.read().expect("poisoned").get(alpn).cloned() -327 } +313async fn shutdown_timeout(alpn: Vec<u8>, handler: Arc<dyn DynProtocolHandler>) -> Option<()> { +314 if let Err(_elapsed) = time::timeout(SHUTDOWN_TIMEOUT, handler.shutdown()).await { +315 debug!( +316 alpn = String::from_utf8_lossy(&alpn).to_string(), +317 "Protocol handler exceeded the shutdown timeout and was aborted" +318 ); +319 None +320 } else { +321 Some(()) +322 } +323} +324 +325/// A typed map of protocol handlers, mapping them from ALPNs. +326#[derive(Debug, Default)] +327pub(crate) struct ProtocolMap(std::sync::RwLock<BTreeMap<Vec<u8>, Arc<dyn DynProtocolHandler>>>); 328 -329 /// Inserts a protocol handler. -330 pub(crate) fn insert( -331 &self, -332 alpn: Vec<u8>, -333 handler: Arc<dyn DynProtocolHandler>, -334 ) -> Option<Arc<dyn DynProtocolHandler>> { -335 self.0.write().expect("poisoned").insert(alpn, handler) -336 } -337 -338 pub(crate) fn remove(&self, alpn: &[u8]) -> Option<Arc<dyn DynProtocolHandler>> { -339 self.0.write().expect("poisoned").remove(alpn) -340 } -341 -342 /// Returns an iterator of all registered ALPN protocol identifiers. -343 pub(crate) fn alpns(&self) -> Vec<Vec<u8>> { -344 self.0.read().expect("poisoned").keys().cloned().collect() -345 } -346 -347 /// Shuts down all protocol handlers. -348 /// -349 /// Calls and awaits [`ProtocolHandler::shutdown`] for all registered handlers concurrently. -350 pub(crate) async fn shutdown(&self) { -351 let handlers: Vec<_> = { -352 let inner = self.0.read().expect("poisoned"); -353 inner -354 .values() -355 .cloned() -356 .map(|handler| shutdown_timeout(handler)) -357 .collect() -358 }; -359 join_all(handlers).await; -360 } -361} -362 -363impl Router { -364 /// Creates a new [`Router`] using given [`Endpoint`]. -365 pub fn builder(endpoint: Endpoint) -> RouterBuilder { -366 RouterBuilder::new(endpoint) -367 } -368 -369 /// Returns the [`Endpoint`] stored in this router. -370 pub fn endpoint(&self) -> &Endpoint { -371 &self.endpoint +329impl ProtocolMap { +330 /// Returns the registered protocol handler for an ALPN as a [`Arc<dyn ProtocolHandler>`]. +331 pub(crate) fn get(&self, alpn: &[u8]) -> Option<Arc<dyn DynProtocolHandler>> { +332 self.0.read().expect("poisoned").get(alpn).cloned() +333 } +334 +335 /// Inserts a protocol handler. +336 pub(crate) fn insert( +337 &self, +338 alpn: Vec<u8>, +339 handler: Arc<dyn DynProtocolHandler>, +340 ) -> Option<Arc<dyn DynProtocolHandler>> { +341 self.0.write().expect("poisoned").insert(alpn, handler) +342 } +343 +344 pub(crate) fn remove(&self, alpn: &[u8]) -> Option<Arc<dyn DynProtocolHandler>> { +345 self.0.write().expect("poisoned").remove(alpn) +346 } +347 +348 /// Returns an iterator of all registered ALPN protocol identifiers. +349 pub(crate) fn alpns(&self) -> Vec<Vec<u8>> { +350 self.0.read().expect("poisoned").keys().cloned().collect() +351 } +352 +353 /// Shuts down all protocol handlers. +354 /// +355 /// Calls and awaits [`ProtocolHandler::shutdown`] for all registered handlers concurrently. +356 pub(crate) async fn shutdown(&self) { +357 let mut futures = Vec::new(); +358 { +359 let mut inner = self.0.write().expect("poisoned"); +360 while let Some((alpn, handler)) = inner.pop_first() { +361 futures.push(shutdown_timeout(alpn, handler)); +362 } +363 } +364 join_all(futures).await; +365 } +366} +367 +368impl Router { +369 /// Creates a new [`Router`] using given [`Endpoint`]. +370 pub fn builder(endpoint: Endpoint) -> RouterBuilder { +371 RouterBuilder::new(endpoint) 372 } 373 -374 /// Checks if the router is already shutdown. -375 pub fn is_shutdown(&self) -> bool { -376 self.cancel_token.is_cancelled() +374 /// Returns the [`Endpoint`] stored in this router. +375 pub fn endpoint(&self) -> &Endpoint { +376 &self.endpoint 377 } 378 -379 /// Adds a protocol to the list of accepted protocols. -380 /// -381 /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection -382 /// with this `alpn`. -383 /// -384 /// Once the function yields, new connections with this `alpn` will be handled. +379 /// Checks if the router is already shutdown. +380 pub fn is_shutdown(&self) -> bool { +381 self.cancel_token.is_cancelled() +382 } +383 +384 /// Adds a protocol to the list of accepted protocols. 385 /// -386 /// If a protocol handler was already registered for `alpn`, the previous handler will be shutdown. -387 /// -388 /// Returns `true` if -389 pub async fn accept( -390 &self, -391 alpn: impl AsRef<[u8]>, -392 handler: impl ProtocolHandler, -393 ) -> Result<AddProtocolOutcome, RouterError> { -394 let (reply, reply_rx) = oneshot::channel(); -395 self.tx -396 .send(ToRouterTask::Accept { -397 alpn: alpn.as_ref().to_vec(), -398 handler: Arc::new(handler), -399 reply, -400 }) -401 .await -402 .map_err(|_| RouterError::Closed {})?; -403 reply_rx.await.map_err(|_| RouterError::Closed {}) -404 } -405 -406 /// Stops accepting a protocol. -407 /// -408 /// Note that this has only an effect on new connections. Existing connections that were -409 /// accepted with `alpn` won't be closed when calling [`Router::stop_accepting`]. -410 pub async fn stop_accepting(&self, alpn: impl AsRef<[u8]>) -> Result<(), StopAcceptingError> { -411 let (reply, reply_rx) = oneshot::channel(); -412 self.tx -413 .send(ToRouterTask::StopAccepting { -414 alpn: alpn.as_ref().to_vec(), -415 reply, -416 }) -417 .await -418 .map_err(|_| StopAcceptingError::Closed {})?; -419 reply_rx.await.map_err(|_| StopAcceptingError::Closed {})? -420 } -421 -422 /// Shuts down the accept loop cleanly. -423 /// -424 /// When this function returns, all [`ProtocolHandler`]s will be shutdown and -425 /// `Endpoint::close` will have been called. -426 /// -427 /// If already shutdown, it returns `Ok`. +386 /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection +387 /// with this `alpn`. +388 /// +389 /// Once the function yields, new connections with this `alpn` will be handled. +390 /// +391 /// If a protocol handler was already registered for `alpn`, the previous handler will be shutdown. +392 /// +393 /// Returns `true` if +394 pub async fn accept( +395 &self, +396 alpn: impl AsRef<[u8]>, +397 handler: impl ProtocolHandler, +398 ) -> Result<AddProtocolOutcome, RouterError> { +399 let (reply, reply_rx) = oneshot::channel(); +400 self.tx +401 .send(ToRouterTask::Accept { +402 alpn: alpn.as_ref().to_vec(), +403 handler: Arc::new(handler), +404 reply, +405 }) +406 .await +407 .map_err(|_| RouterError::Closed {})?; +408 reply_rx.await.map_err(|_| RouterError::Closed {}) +409 } +410 +411 /// Stops accepting a protocol. +412 /// +413 /// Note that this has only an effect on new connections. Existing connections that were +414 /// accepted with `alpn` won't be closed when calling [`Router::stop_accepting`]. +415 pub async fn stop_accepting(&self, alpn: impl AsRef<[u8]>) -> Result<(), StopAcceptingError> { +416 let (reply, reply_rx) = oneshot::channel(); +417 self.tx +418 .send(ToRouterTask::StopAccepting { +419 alpn: alpn.as_ref().to_vec(), +420 reply, +421 }) +422 .await +423 .map_err(|_| StopAcceptingError::Closed {})?; +424 reply_rx.await.map_err(|_| StopAcceptingError::Closed {})? +425 } +426 +427 /// Shuts down the accept loop cleanly. 428 /// -429 /// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate -430 /// that panic into the result here. -431 pub async fn shutdown(&self) -> Result<(), n0_future::task::JoinError> { -432 if self.is_shutdown() { -433 return Ok(()); -434 } -435 -436 // Trigger shutdown of the main run task by activating the cancel token. -437 self.cancel_token.cancel(); -438 -439 // Wait for the main task to terminate. -440 if let Some(task) = self.task.lock().await.take() { -441 task.await?; -442 } +429 /// When this function returns, all [`ProtocolHandler`]s will be shutdown and +430 /// `Endpoint::close` will have been called. +431 /// +432 /// If already shutdown, it returns `Ok`. +433 /// +434 /// If some [`ProtocolHandler`] panicked in the accept loop, this will propagate +435 /// that panic into the result here. +436 pub async fn shutdown(&self) -> Result<(), n0_future::task::JoinError> { +437 if self.is_shutdown() { +438 return Ok(()); +439 } +440 +441 // Trigger shutdown of the main run task by activating the cancel token. +442 self.cancel_token.cancel(); 443 -444 Ok(()) -445 } -446} -447 -448impl RouterBuilder { -449 /// Creates a new router builder using given [`Endpoint`]. -450 pub fn new(endpoint: Endpoint) -> Self { -451 Self { -452 endpoint, -453 protocols: ProtocolMap::default(), -454 } -455 } -456 -457 /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection -458 /// with this `alpn`. -459 pub fn accept(self, alpn: impl AsRef<[u8]>, handler: impl ProtocolHandler) -> Self { -460 self.protocols -461 .insert(alpn.as_ref().to_vec(), Arc::new(handler)); -462 self -463 } -464 -465 /// Returns the [`Endpoint`] of the node. -466 pub fn endpoint(&self) -> &Endpoint { -467 &self.endpoint -468 } +444 // Wait for the main task to terminate. +445 if let Some(task) = self.task.lock().await.take() { +446 task.await?; +447 } +448 +449 Ok(()) +450 } +451} +452 +453impl RouterBuilder { +454 /// Creates a new router builder using given [`Endpoint`]. +455 pub fn new(endpoint: Endpoint) -> Self { +456 Self { +457 endpoint, +458 protocols: ProtocolMap::default(), +459 } +460 } +461 +462 /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection +463 /// with this `alpn`. +464 pub fn accept(self, alpn: impl AsRef<[u8]>, handler: impl ProtocolHandler) -> Self { +465 self.protocols +466 .insert(alpn.as_ref().to_vec(), Arc::new(handler)); +467 self +468 } 469 -470 /// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`]. -471 pub fn spawn(self) -> Router { -472 // Update the endpoint with our alpns. -473 self.endpoint.set_alpns(self.protocols.alpns()); +470 /// Returns the [`Endpoint`] of the node. +471 pub fn endpoint(&self) -> &Endpoint { +472 &self.endpoint +473 } 474 -475 let protocols = Arc::new(self.protocols); -476 -477 let mut join_set = JoinSet::new(); -478 let endpoint = self.endpoint.clone(); +475 /// Spawns an accept loop and returns a handle to it encapsulated as the [`Router`]. +476 pub fn spawn(self) -> Router { +477 // Update the endpoint with our alpns. +478 self.endpoint.set_alpns(self.protocols.alpns()); 479 -480 // Our own shutdown works with a cancellation token. -481 let cancel = CancellationToken::new(); -482 let cancel_token = cancel.clone(); -483 -484 let (tx, mut rx) = mpsc::channel(8); -485 -486 let run_loop_fut = async move { -487 // Make sure to cancel the token, if this future ever exits. -488 let _cancel_guard = cancel_token.clone().drop_guard(); -489 // We create a separate cancellation token to stop any `ProtocolHandler::accept` futures -490 // that are still running after `ProtocolHandler::shutdown` was called. -491 let handler_cancel_token = CancellationToken::new(); -492 -493 loop { -494 tokio::select! { -495 biased; -496 _ = cancel_token.cancelled() => { -497 break; -498 }, -499 Some(msg) = rx.recv() => { -500 match msg { -501 ToRouterTask::Accept { alpn, handler, reply } => { -502 let outcome = if let Some(previous) = protocols.insert(alpn, handler) { -503 join_set.spawn(shutdown_timeout(previous)); -504 AddProtocolOutcome::Replaced -505 } else { -506 AddProtocolOutcome::Inserted -507 }; -508 endpoint.set_alpns(protocols.alpns()); -509 reply.send(outcome).ok(); -510 } -511 ToRouterTask::StopAccepting { alpn, reply } => { -512 if let Some(handler) = protocols.remove(&alpn) { -513 join_set.spawn(shutdown_timeout(handler)); -514 endpoint.set_alpns(protocols.alpns()); -515 reply.send(Ok(())).ok(); -516 } else { -517 reply.send(Err(StopAcceptingError::UnknownAlpn {})).ok(); -518 } -519 } -520 } -521 } -522 // handle task terminations and quit on panics. -523 Some(res) = join_set.join_next() => { -524 match res { -525 Err(outer) => { -526 if outer.is_panic() { -527 error!("Task panicked: {outer:?}"); -528 break; -529 } else if outer.is_cancelled() { -530 trace!("Task cancelled: {outer:?}"); -531 } else { -532 error!("Task failed: {outer:?}"); +480 let protocols = Arc::new(self.protocols); +481 +482 let mut join_set = JoinSet::new(); +483 let endpoint = self.endpoint.clone(); +484 +485 // Our own shutdown works with a cancellation token. +486 let cancel = CancellationToken::new(); +487 let cancel_token = cancel.clone(); +488 +489 let (tx, mut rx) = mpsc::channel(8); +490 +491 let run_loop_fut = async move { +492 // Make sure to cancel the token, if this future ever exits. +493 let _cancel_guard = cancel_token.clone().drop_guard(); +494 // We create a separate cancellation token to stop any `ProtocolHandler::accept` futures +495 // that are still running after `ProtocolHandler::shutdown` was called. +496 let handler_cancel_token = CancellationToken::new(); +497 +498 loop { +499 tokio::select! { +500 biased; +501 _ = cancel_token.cancelled() => { +502 break; +503 }, +504 Some(msg) = rx.recv() => { +505 match msg { +506 ToRouterTask::Accept { alpn, handler, reply } => { +507 let outcome = if let Some(previous) = protocols.insert(alpn.clone(), handler) { +508 join_set.spawn(shutdown_timeout(alpn, previous)); +509 AddProtocolOutcome::Replaced +510 } else { +511 AddProtocolOutcome::Inserted +512 }; +513 endpoint.set_alpns(protocols.alpns()); +514 reply.send(outcome).ok(); +515 } +516 ToRouterTask::StopAccepting { alpn, reply } => { +517 if let Some(handler) = protocols.remove(&alpn) { +518 join_set.spawn(shutdown_timeout(alpn, handler)); +519 endpoint.set_alpns(protocols.alpns()); +520 reply.send(Ok(())).ok(); +521 } else { +522 reply.send(Err(StopAcceptingError::UnknownAlpn {})).ok(); +523 } +524 } +525 } +526 } +527 // handle task terminations and quit on panics. +528 Some(res) = join_set.join_next() => { +529 match res { +530 Err(outer) => { +531 if outer.is_panic() { +532 error!("Task panicked: {outer:?}"); 533 break; -534 } -535 } -536 Ok(Some(())) => { -537 trace!("Task finished"); -538 } -539 Ok(None) => { -540 trace!("Task cancelled"); -541 } -542 } -543 }, -544 -545 // handle incoming p2p connections. -546 incoming = endpoint.accept() => { -547 let Some(incoming) = incoming else { -548 break; // Endpoint is closed. -549 }; -550 -551 let protocols = protocols.clone(); -552 let token = handler_cancel_token.child_token(); -553 join_set.spawn(async move { -554 token.run_until_cancelled(handle_connection(incoming, protocols)).await -555 }.instrument(info_span!("router.accept"))); -556 }, -557 } -558 } -559 -560 // We first shutdown the protocol handlers to give them a chance to close connections gracefully. -561 protocols.shutdown().await; -562 // We now cancel the remaining `ProtocolHandler::accept` futures. -563 handler_cancel_token.cancel(); -564 // Now we close the endpoint. This will force-close all connections that are not yet closed. -565 endpoint.close().await; -566 // Finally, we abort the remaining accept tasks. This should be a noop because we already cancelled -567 // the futures above. -568 tracing::debug!("Shutting down remaining tasks"); -569 join_set.abort_all(); -570 while let Some(res) = join_set.join_next().await { -571 match res { -572 Err(err) if err.is_panic() => error!("Task panicked: {err:?}"), -573 _ => {} -574 } -575 } -576 }; -577 let task = task::spawn(run_loop_fut); -578 let task = AbortOnDropHandle::new(task); -579 -580 Router { -581 endpoint: self.endpoint, -582 task: Arc::new(Mutex::new(Some(task))), -583 cancel_token: cancel, -584 tx, -585 } -586 } -587} -588 -589async fn handle_connection(incoming: crate::endpoint::Incoming, protocols: Arc<ProtocolMap>) { -590 let mut connecting = match incoming.accept() { -591 Ok(conn) => conn, -592 Err(err) => { -593 warn!("Ignoring connection: accepting failed: {err:#}"); -594 return; -595 } -596 }; -597 let alpn = match connecting.alpn().await { -598 Ok(alpn) => alpn, -599 Err(err) => { -600 warn!("Ignoring connection: invalid handshake: {err:#}"); -601 return; -602 } -603 }; -604 let Some(handler) = protocols.get(&alpn) else { -605 warn!("Ignoring connection: unsupported ALPN protocol"); -606 return; -607 }; -608 match handler.on_connecting(connecting).await { -609 Ok(connection) => { -610 if let Err(err) = handler.accept(connection).await { -611 warn!("Handling incoming connection ended with error: {err}"); -612 } -613 } -614 Err(err) => { -615 warn!("Handling incoming connecting ended with error: {err}"); -616 } -617 } -618} -619 -620/// Wraps an existing protocol, limiting its access, -621/// based on the provided function. -622/// -623/// Any refused connection will be closed with an error code of `0` and reason `not allowed`. -624#[derive(derive_more::Debug, Clone)] -625pub struct AccessLimit<P: ProtocolHandler + Clone> { -626 proto: P, -627 #[debug("limiter")] -628 limiter: Arc<dyn Fn(NodeId) -> bool + Send + Sync + 'static>, -629} -630 -631impl<P: ProtocolHandler + Clone> AccessLimit<P> { -632 /// Create a new `AccessLimit`. -633 /// -634 /// The function should return `true` for nodes that are allowed to -635 /// connect, and `false` otherwise. -636 pub fn new<F>(proto: P, limiter: F) -> Self -637 where -638 F: Fn(NodeId) -> bool + Send + Sync + 'static, -639 { -640 Self { -641 proto, -642 limiter: Arc::new(limiter), -643 } -644 } -645} -646 -647impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> { -648 fn on_connecting( -649 &self, -650 conn: Connecting, -651 ) -> impl Future<Output = Result<Connection, AcceptError>> + Send { -652 self.proto.on_connecting(conn) -653 } -654 -655 async fn accept(&self, conn: Connection) -> Result<(), AcceptError> { -656 let remote = conn.remote_node_id()?; -657 let is_allowed = (self.limiter)(remote); -658 if !is_allowed { -659 conn.close(0u32.into(), b"not allowed"); -660 return Err(NotAllowedSnafu.build()); -661 } -662 self.proto.accept(conn).await?; -663 Ok(()) -664 } -665 -666 fn shutdown(&self) -> impl Future<Output = ()> + Send { -667 self.proto.shutdown() -668 } -669} +534 } else if outer.is_cancelled() { +535 trace!("Task cancelled: {outer:?}"); +536 } else { +537 error!("Task failed: {outer:?}"); +538 break; +539 } +540 } +541 Ok(Some(())) => { +542 trace!("Task finished"); +543 } +544 Ok(None) => { +545 trace!("Task cancelled"); +546 } +547 } +548 }, +549 +550 // handle incoming p2p connections. +551 incoming = endpoint.accept() => { +552 let Some(incoming) = incoming else { +553 break; // Endpoint is closed. +554 }; +555 +556 let protocols = protocols.clone(); +557 let token = handler_cancel_token.child_token(); +558 join_set.spawn(async move { +559 token.run_until_cancelled(handle_connection(incoming, protocols)).await +560 }.instrument(info_span!("router.accept"))); +561 }, +562 } +563 } +564 +565 // We first shutdown the protocol handlers to give them a chance to close connections gracefully. +566 protocols.shutdown().await; +567 // We now cancel the remaining `ProtocolHandler::accept` futures. +568 handler_cancel_token.cancel(); +569 // Now we close the endpoint. This will force-close all connections that are not yet closed. +570 endpoint.close().await; +571 // Finally, we abort the remaining accept tasks. This should be a noop because we already cancelled +572 // the futures above. +573 debug!("Shutting down remaining tasks"); +574 join_set.abort_all(); +575 while let Some(res) = join_set.join_next().await { +576 match res { +577 Err(err) if err.is_panic() => error!("Task panicked: {err:?}"), +578 _ => {} +579 } +580 } +581 }; +582 let task = task::spawn(run_loop_fut); +583 let task = AbortOnDropHandle::new(task); +584 +585 Router { +586 endpoint: self.endpoint, +587 task: Arc::new(Mutex::new(Some(task))), +588 cancel_token: cancel, +589 tx, +590 } +591 } +592} +593 +594async fn handle_connection(incoming: crate::endpoint::Incoming, protocols: Arc<ProtocolMap>) { +595 let mut connecting = match incoming.accept() { +596 Ok(conn) => conn, +597 Err(err) => { +598 warn!("Ignoring connection: accepting failed: {err:#}"); +599 return; +600 } +601 }; +602 let alpn = match connecting.alpn().await { +603 Ok(alpn) => alpn, +604 Err(err) => { +605 warn!("Ignoring connection: invalid handshake: {err:#}"); +606 return; +607 } +608 }; +609 let Some(handler) = protocols.get(&alpn) else { +610 warn!("Ignoring connection: unsupported ALPN protocol"); +611 return; +612 }; +613 match handler.on_connecting(connecting).await { +614 Ok(connection) => { +615 if let Err(err) = handler.accept(connection).await { +616 warn!("Handling incoming connection ended with error: {err}"); +617 } +618 } +619 Err(err) => { +620 warn!("Handling incoming connecting ended with error: {err}"); +621 } +622 } +623} +624 +625/// Wraps an existing protocol, limiting its access, +626/// based on the provided function. +627/// +628/// Any refused connection will be closed with an error code of `0` and reason `not allowed`. +629#[derive(derive_more::Debug, Clone)] +630pub struct AccessLimit<P: ProtocolHandler + Clone> { +631 proto: P, +632 #[debug("limiter")] +633 limiter: Arc<dyn Fn(NodeId) -> bool + Send + Sync + 'static>, +634} +635 +636impl<P: ProtocolHandler + Clone> AccessLimit<P> { +637 /// Create a new `AccessLimit`. +638 /// +639 /// The function should return `true` for nodes that are allowed to +640 /// connect, and `false` otherwise. +641 pub fn new<F>(proto: P, limiter: F) -> Self +642 where +643 F: Fn(NodeId) -> bool + Send + Sync + 'static, +644 { +645 Self { +646 proto, +647 limiter: Arc::new(limiter), +648 } +649 } +650} +651 +652impl<P: ProtocolHandler + Clone> ProtocolHandler for AccessLimit<P> { +653 fn on_connecting( +654 &self, +655 conn: Connecting, +656 ) -> impl Future<Output = Result<Connection, AcceptError>> + Send { +657 self.proto.on_connecting(conn) +658 } +659 +660 async fn accept(&self, conn: Connection) -> Result<(), AcceptError> { +661 let remote = conn.remote_node_id()?; +662 let is_allowed = (self.limiter)(remote); +663 if !is_allowed { +664 conn.close(0u32.into(), b"not allowed"); +665 return Err(NotAllowedSnafu.build()); +666 } +667 self.proto.accept(conn).await?; +668 Ok(()) +669 } 670 -671#[cfg(test)] -672mod tests { -673 use std::{sync::Mutex, time::Duration}; -674 -675 use iroh_base::NodeAddr; -676 use n0_snafu::{Result, ResultExt}; -677 use n0_watcher::Watcher; -678 use quinn::{ApplicationClose, TransportErrorCode}; +671 fn shutdown(&self) -> impl Future<Output = ()> + Send { +672 self.proto.shutdown() +673 } +674} +675 +676#[cfg(test)] +677mod tests { +678 use std::{sync::Mutex, time::Duration}; 679 -680 use super::*; -681 use crate::{ -682 endpoint::{ConnectError, ConnectionError}, -683 RelayMode, -684 }; -685 -686 #[tokio::test] -687 async fn test_shutdown() -> Result { -688 let endpoint = Endpoint::builder().bind().await?; -689 let router = Router::builder(endpoint.clone()).spawn(); +680 use iroh_base::NodeAddr; +681 use n0_snafu::{Result, ResultExt}; +682 use n0_watcher::Watcher; +683 use quinn::{ApplicationClose, TransportErrorCode}; +684 +685 use super::*; +686 use crate::{ +687 endpoint::{ConnectError, ConnectionError}, +688 RelayMode, +689 }; 690 -691 assert!(!router.is_shutdown()); -692 assert!(!endpoint.is_closed()); -693 -694 router.shutdown().await.e()?; +691 #[tokio::test] +692 async fn test_shutdown() -> Result { +693 let endpoint = Endpoint::builder().bind().await?; +694 let router = Router::builder(endpoint.clone()).spawn(); 695 -696 assert!(router.is_shutdown()); -697 assert!(endpoint.is_closed()); +696 assert!(!router.is_shutdown()); +697 assert!(!endpoint.is_closed()); 698 -699 Ok(()) -700 } -701 -702 // The protocol definition: -703 #[derive(Debug, Clone)] -704 struct Echo; -705 -706 const ECHO_ALPN: &[u8] = b"/iroh/echo/1"; -707 -708 impl ProtocolHandler for Echo { -709 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { -710 println!("accepting echo"); -711 let (mut send, mut recv) = connection.accept_bi().await?; +699 router.shutdown().await.e()?; +700 +701 assert!(router.is_shutdown()); +702 assert!(endpoint.is_closed()); +703 +704 Ok(()) +705 } +706 +707 // The protocol definition: +708 #[derive(Debug, Clone)] +709 struct Echo; +710 +711 const ECHO_ALPN: &[u8] = b"/iroh/echo/1"; 712 -713 // Echo any bytes received back directly. -714 let _bytes_sent = tokio::io::copy(&mut recv, &mut send).await?; -715 -716 send.finish()?; -717 connection.closed().await; -718 -719 Ok(()) -720 } -721 } -722 -723 #[tokio::test] -724 async fn test_limiter() -> Result { -725 // tracing_subscriber::fmt::try_init().ok(); -726 let e1 = Endpoint::builder() -727 .relay_mode(RelayMode::Disabled) -728 .bind() -729 .await?; -730 // deny all access -731 let proto = AccessLimit::new(Echo, |_node_id| false); -732 let r1 = Router::builder(e1.clone()).accept(ECHO_ALPN, proto).spawn(); -733 -734 let addr1 = r1.endpoint().node_addr().initialized().await?; -735 dbg!(&addr1); -736 let e2 = Endpoint::builder() -737 .relay_mode(RelayMode::Disabled) -738 .bind() -739 .await?; -740 -741 println!("connecting"); -742 let conn = e2.connect(addr1, ECHO_ALPN).await?; -743 -744 let (_send, mut recv) = conn.open_bi().await.e()?; -745 let response = recv.read_to_end(1000).await.unwrap_err(); -746 assert!(format!("{:#?}", response).contains("not allowed")); -747 -748 r1.shutdown().await.e()?; -749 e2.close().await; -750 -751 Ok(()) -752 } -753 -754 #[tokio::test] -755 async fn test_graceful_shutdown() -> Result { -756 #[derive(Debug, Clone, Default)] -757 struct TestProtocol { -758 connections: Arc<Mutex<Vec<Connection>>>, -759 } -760 -761 const TEST_ALPN: &[u8] = b"/iroh/test/1"; -762 -763 impl ProtocolHandler for TestProtocol { -764 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { -765 self.connections.lock().expect("poisoned").push(connection); -766 Ok(()) -767 } -768 -769 async fn shutdown(&self) { -770 tokio::time::sleep(Duration::from_millis(100)).await; -771 let mut connections = self.connections.lock().expect("poisoned"); -772 for conn in connections.drain(..) { -773 conn.close(42u32.into(), b"shutdown"); -774 } -775 } -776 } -777 -778 eprintln!("creating ep1"); -779 let endpoint = Endpoint::builder() -780 .relay_mode(RelayMode::Disabled) -781 .bind() -782 .await?; -783 let router = Router::builder(endpoint) -784 .accept(TEST_ALPN, TestProtocol::default()) -785 .spawn(); -786 eprintln!("waiting for node addr"); -787 let addr = router.endpoint().node_addr().initialized().await?; -788 -789 eprintln!("creating ep2"); -790 let endpoint2 = Endpoint::builder() -791 .relay_mode(RelayMode::Disabled) -792 .bind() -793 .await?; -794 eprintln!("connecting to {:?}", addr); -795 let conn = endpoint2.connect(addr, TEST_ALPN).await?; -796 -797 eprintln!("starting shutdown"); -798 router.shutdown().await.e()?; -799 -800 eprintln!("waiting for closed conn"); -801 let reason = conn.closed().await; -802 assert_eq!( -803 reason, -804 ConnectionError::ApplicationClosed(ApplicationClose { -805 error_code: 42u32.into(), -806 reason: b"shutdown".to_vec().into() -807 }) -808 ); -809 Ok(()) -810 } -811 -812 #[tokio::test] -813 async fn test_add_and_remove_protocol() -> Result { -814 async fn connect_assert_ok( -815 endpoint: &Endpoint, -816 addr: &NodeAddr, -817 alpn: &[u8], -818 expected_code: u32, -819 ) { -820 let conn = endpoint -821 .connect(addr.clone(), alpn) -822 .await -823 .expect("expected connection to succeed"); -824 let reason = conn.closed().await; -825 assert!(matches!(reason, -826 ConnectionError::ApplicationClosed(ApplicationClose { error_code, .. }) if error_code == expected_code.into() -827 )); -828 } -829 -830 async fn connect_assert_fail(endpoint: &Endpoint, addr: &NodeAddr, alpn: &[u8]) { -831 let conn = endpoint.connect(addr.clone(), alpn).await; -832 assert!(matches!( -833 &conn, -834 Err(ConnectError::Connection { source, .. }) -835 if matches!( -836 source.as_ref(), -837 ConnectionError::ConnectionClosed(frame) -838 if frame.error_code == TransportErrorCode::crypto(rustls::AlertDescription::NoApplicationProtocol.into()) -839 ) -840 )); -841 } -842 -843 #[derive(Debug, Clone, Default)] -844 struct TestProtocol(u32); -845 -846 const ALPN_1: &[u8] = b"/iroh/test/1"; -847 const ALPN_2: &[u8] = b"/iroh/test/2"; -848 -849 impl ProtocolHandler for TestProtocol { -850 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { -851 connection.close(self.0.into(), b"bye"); -852 Ok(()) -853 } -854 } -855 -856 let server = Endpoint::builder() -857 .relay_mode(RelayMode::Disabled) -858 .bind() -859 .await?; -860 let router = Router::builder(server) -861 .accept(ALPN_1, TestProtocol(1)) -862 .spawn(); -863 -864 let addr = router.endpoint().node_addr().initialized().await?; -865 -866 let client = Endpoint::builder() -867 .relay_mode(RelayMode::Disabled) -868 .bind() -869 .await?; +713 impl ProtocolHandler for Echo { +714 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { +715 println!("accepting echo"); +716 let (mut send, mut recv) = connection.accept_bi().await?; +717 +718 // Echo any bytes received back directly. +719 let _bytes_sent = tokio::io::copy(&mut recv, &mut send).await?; +720 +721 send.finish()?; +722 connection.closed().await; +723 +724 Ok(()) +725 } +726 } +727 +728 #[tokio::test] +729 async fn test_limiter() -> Result { +730 // tracing_subscriber::fmt::try_init().ok(); +731 let e1 = Endpoint::builder() +732 .relay_mode(RelayMode::Disabled) +733 .bind() +734 .await?; +735 // deny all access +736 let proto = AccessLimit::new(Echo, |_node_id| false); +737 let r1 = Router::builder(e1.clone()).accept(ECHO_ALPN, proto).spawn(); +738 +739 let addr1 = r1.endpoint().node_addr().initialized().await?; +740 dbg!(&addr1); +741 let e2 = Endpoint::builder() +742 .relay_mode(RelayMode::Disabled) +743 .bind() +744 .await?; +745 +746 println!("connecting"); +747 let conn = e2.connect(addr1, ECHO_ALPN).await?; +748 +749 let (_send, mut recv) = conn.open_bi().await.e()?; +750 let response = recv.read_to_end(1000).await.unwrap_err(); +751 assert!(format!("{:#?}", response).contains("not allowed")); +752 +753 r1.shutdown().await.e()?; +754 e2.close().await; +755 +756 Ok(()) +757 } +758 +759 #[tokio::test] +760 async fn test_graceful_shutdown() -> Result { +761 #[derive(Debug, Clone, Default)] +762 struct TestProtocol { +763 connections: Arc<Mutex<Vec<Connection>>>, +764 } +765 +766 const TEST_ALPN: &[u8] = b"/iroh/test/1"; +767 +768 impl ProtocolHandler for TestProtocol { +769 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { +770 self.connections.lock().expect("poisoned").push(connection); +771 Ok(()) +772 } +773 +774 async fn shutdown(&self) { +775 tokio::time::sleep(Duration::from_millis(100)).await; +776 let mut connections = self.connections.lock().expect("poisoned"); +777 for conn in connections.drain(..) { +778 conn.close(42u32.into(), b"shutdown"); +779 } +780 } +781 } +782 +783 eprintln!("creating ep1"); +784 let endpoint = Endpoint::builder() +785 .relay_mode(RelayMode::Disabled) +786 .bind() +787 .await?; +788 let router = Router::builder(endpoint) +789 .accept(TEST_ALPN, TestProtocol::default()) +790 .spawn(); +791 eprintln!("waiting for node addr"); +792 let addr = router.endpoint().node_addr().initialized().await?; +793 +794 eprintln!("creating ep2"); +795 let endpoint2 = Endpoint::builder() +796 .relay_mode(RelayMode::Disabled) +797 .bind() +798 .await?; +799 eprintln!("connecting to {:?}", addr); +800 let conn = endpoint2.connect(addr, TEST_ALPN).await?; +801 +802 eprintln!("starting shutdown"); +803 router.shutdown().await.e()?; +804 +805 eprintln!("waiting for closed conn"); +806 let reason = conn.closed().await; +807 assert_eq!( +808 reason, +809 ConnectionError::ApplicationClosed(ApplicationClose { +810 error_code: 42u32.into(), +811 reason: b"shutdown".to_vec().into() +812 }) +813 ); +814 Ok(()) +815 } +816 +817 #[tokio::test] +818 async fn test_add_and_remove_protocol() -> Result { +819 async fn connect_assert_ok( +820 endpoint: &Endpoint, +821 addr: &NodeAddr, +822 alpn: &[u8], +823 expected_code: u32, +824 ) { +825 let conn = endpoint +826 .connect(addr.clone(), alpn) +827 .await +828 .expect("expected connection to succeed"); +829 let reason = conn.closed().await; +830 assert!(matches!(reason, +831 ConnectionError::ApplicationClosed(ApplicationClose { error_code, .. }) if error_code == expected_code.into() +832 )); +833 } +834 +835 async fn connect_assert_fail(endpoint: &Endpoint, addr: &NodeAddr, alpn: &[u8]) { +836 let conn = endpoint.connect(addr.clone(), alpn).await; +837 assert!(matches!( +838 &conn, +839 Err(ConnectError::Connection { source, .. }) +840 if matches!( +841 source.as_ref(), +842 ConnectionError::ConnectionClosed(frame) +843 if frame.error_code == TransportErrorCode::crypto(rustls::AlertDescription::NoApplicationProtocol.into()) +844 ) +845 )); +846 } +847 +848 #[derive(Debug, Clone, Default)] +849 struct TestProtocol(u32); +850 +851 const ALPN_1: &[u8] = b"/iroh/test/1"; +852 const ALPN_2: &[u8] = b"/iroh/test/2"; +853 +854 impl ProtocolHandler for TestProtocol { +855 async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { +856 connection.close(self.0.into(), b"bye"); +857 Ok(()) +858 } +859 } +860 +861 let server = Endpoint::builder() +862 .relay_mode(RelayMode::Disabled) +863 .bind() +864 .await?; +865 let router = Router::builder(server) +866 .accept(ALPN_1, TestProtocol(1)) +867 .spawn(); +868 +869 let addr = router.endpoint().node_addr().initialized().await?; 870 -871 connect_assert_ok(&client, &addr, ALPN_1, 1).await; -872 connect_assert_fail(&client, &addr, ALPN_2).await; -873 -874 router.stop_accepting(ALPN_1).await?; -875 connect_assert_fail(&client, &addr, ALPN_1).await; -876 connect_assert_fail(&client, &addr, ALPN_2).await; -877 -878 let outcome = router.accept(ALPN_2, TestProtocol(2)).await?; -879 assert_eq!(outcome, AddProtocolOutcome::Inserted); +871 let client = Endpoint::builder() +872 .relay_mode(RelayMode::Disabled) +873 .bind() +874 .await?; +875 +876 connect_assert_ok(&client, &addr, ALPN_1, 1).await; +877 connect_assert_fail(&client, &addr, ALPN_2).await; +878 +879 router.stop_accepting(ALPN_1).await?; 880 connect_assert_fail(&client, &addr, ALPN_1).await; -881 connect_assert_ok(&client, &addr, ALPN_2, 2).await; +881 connect_assert_fail(&client, &addr, ALPN_2).await; 882 -883 let outcome = router.accept(ALPN_1, TestProtocol(3)).await?; +883 let outcome = router.accept(ALPN_2, TestProtocol(2)).await?; 884 assert_eq!(outcome, AddProtocolOutcome::Inserted); -885 connect_assert_ok(&client, &addr, ALPN_1, 3).await; +885 connect_assert_fail(&client, &addr, ALPN_1).await; 886 connect_assert_ok(&client, &addr, ALPN_2, 2).await; 887 -888 let outcome = router.accept(ALPN_1, TestProtocol(4)).await?; -889 assert_eq!(outcome, AddProtocolOutcome::Replaced); -890 connect_assert_ok(&client, &addr, ALPN_1, 4).await; -891 -892 router.stop_accepting(ALPN_2).await?; -893 connect_assert_ok(&client, &addr, ALPN_1, 4).await; -894 connect_assert_fail(&client, &addr, ALPN_2).await; -895 -896 router.stop_accepting(ALPN_1).await?; -897 connect_assert_fail(&client, &addr, ALPN_1).await; -898 connect_assert_fail(&client, &addr, ALPN_2).await; -899 -900 assert!(matches!( -901 router.stop_accepting(ALPN_1).await, -902 Err(StopAcceptingError::UnknownAlpn {}) -903 )); -904 assert!(matches!( -905 router.stop_accepting(ALPN_2).await, -906 Err(StopAcceptingError::UnknownAlpn {}) -907 )); -908 -909 Ok(()) -910 } -911}
    \ No newline at end of file +888 let outcome = router.accept(ALPN_1, TestProtocol(3)).await?; +889 assert_eq!(outcome, AddProtocolOutcome::Inserted); +890 connect_assert_ok(&client, &addr, ALPN_1, 3).await; +891 connect_assert_ok(&client, &addr, ALPN_2, 2).await; +892 +893 let outcome = router.accept(ALPN_1, TestProtocol(4)).await?; +894 assert_eq!(outcome, AddProtocolOutcome::Replaced); +895 connect_assert_ok(&client, &addr, ALPN_1, 4).await; +896 +897 router.stop_accepting(ALPN_2).await?; +898 connect_assert_ok(&client, &addr, ALPN_1, 4).await; +899 connect_assert_fail(&client, &addr, ALPN_2).await; +900 +901 router.stop_accepting(ALPN_1).await?; +902 connect_assert_fail(&client, &addr, ALPN_1).await; +903 connect_assert_fail(&client, &addr, ALPN_2).await; +904 +905 assert!(matches!( +906 router.stop_accepting(ALPN_1).await, +907 Err(StopAcceptingError::UnknownAlpn {}) +908 )); +909 assert!(matches!( +910 router.stop_accepting(ALPN_2).await, +911 Err(StopAcceptingError::UnknownAlpn {}) +912 )); +913 +914 Ok(()) +915 } +916}

    \ No newline at end of file diff --git a/pr/3355/docs/trait.impl/core/convert/trait.From.js b/pr/3355/docs/trait.impl/core/convert/trait.From.js index ddcb7ee7e2..2560c7d601 100644 --- a/pr/3355/docs/trait.impl/core/convert/trait.From.js +++ b/pr/3355/docs/trait.impl/core/convert/trait.From.js @@ -1,9 +1,9 @@ (function() { - var implementors = Object.fromEntries([["iroh",[["impl From<PkarrError> for DiscoveryError"],["impl From<AddNodeAddrError> for ConnectWithOptsError"],["impl From<ConnectWithOptsError> for ConnectError"],["impl From<ConnectionError> for AlpnError"],["impl From<ConnectionError> for ConnectError"],["impl From<ConnectionError> for AcceptError"],["impl From<Box<dyn Error + Send + Sync>> for AcceptError"],["impl From<Error> for AcceptError"],["impl From<DiscoveryItem> for NodeInfo"],["impl From<ClosedStream> for AcceptError"],["impl From<RemoteInfo> for NodeAddr"],["impl From<RemoteNodeIdError> for AcceptError"],["impl<T> From<T> for ConcurrentDiscovery
    where\n T: IntoIterator<Item = Box<dyn Discovery>>,
    "]]],["iroh_base",[["impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for NodeAddr"],["impl From<Url> for RelayUrl"],["impl From<NodeAddr> for NodeTicket"],["impl From<PublicKey> for NodeAddr"],["impl From<RelayUrl> for Url"],["impl From<NodeTicket> for NodeAddr"],["impl From<DecodeError> for KeyParsingError"],["impl From<DecodeError> for ParseError"],["impl From<Error> for KeyParsingError"],["impl From<SigningKey> for SecretKey"],["impl From<VerifyingKey> for PublicKey"],["impl From<[u8; 32]> for SecretKey"]]],["iroh_relay",[["impl From<DialError> for ConnectError"],["impl From<SendError> for SendError"],["impl From<DnsError> for DialError"],["impl From<DecodingError> for ParseError"],["impl From<FrameType> for u8"],["impl From<RecvError> for RecvError"],["impl From<SendError> for ConnectError"],["impl From<SendError> for RecvError"],["impl From<u8> for FrameType"],["impl From<Error> for DialError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<NodeInfo> for NodeAddr"],["impl From<RelayNode> for RelayMap"],["impl From<ConnectError> for Error"],["impl From<ConnectionError> for Error"],["impl From<Elapsed> for DialError"],["impl From<Elapsed> for DnsError"],["impl From<Elapsed> for RecvError"],["impl From<Elapsed> for SendError"],["impl From<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for RecvError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<JoinError> for SupervisorError"],["impl From<NoInitialCipherSuite> for Error"],["impl From<NodeAddr> for NodeData"],["impl From<NodeAddr> for NodeInfo"],["impl From<RecvError> for Error"],["impl From<RelayUrl> for RelayMap"],["impl From<RelayUrl> for RelayNode"],["impl From<ResolveError> for DnsError"],["impl From<Resolver<GenericConnector<TokioRuntimeProvider>>> for DnsResolver"],["impl From<SignedPacketBuildError> for EncodingError"],["impl From<TxtLookup> for TxtLookup"]]]]); + var implementors = Object.fromEntries([["iroh",[["impl From<PkarrError> for DiscoveryError"],["impl From<AddNodeAddrError> for ConnectWithOptsError"],["impl From<ConnectWithOptsError> for ConnectError"],["impl From<ConnectionError> for AlpnError"],["impl From<ConnectionError> for ConnectError"],["impl From<ConnectionError> for AcceptError"],["impl From<Box<dyn Error + Send + Sync>> for AcceptError"],["impl From<Error> for AcceptError"],["impl From<DiscoveryItem> for NodeInfo"],["impl From<ClosedStream> for AcceptError"],["impl From<RemoteInfo> for NodeAddr"],["impl From<RemoteNodeIdError> for AcceptError"],["impl<T> From<T> for ConcurrentDiscovery
    where\n T: IntoIterator<Item = Box<dyn Discovery>>,
    "]]],["iroh_base",[["impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for NodeAddr"],["impl From<Url> for RelayUrl"],["impl From<NodeAddr> for NodeTicket"],["impl From<PublicKey> for NodeAddr"],["impl From<RelayUrl> for Url"],["impl From<NodeTicket> for NodeAddr"],["impl From<DecodeError> for KeyParsingError"],["impl From<DecodeError> for ParseError"],["impl From<Error> for KeyParsingError"],["impl From<SigningKey> for SecretKey"],["impl From<VerifyingKey> for PublicKey"],["impl From<[u8; 32]> for SecretKey"]]],["iroh_relay",[["impl From<DialError> for ConnectError"],["impl From<SendError> for SendError"],["impl From<DnsError> for DialError"],["impl From<DecodingError> for ParseError"],["impl From<FrameType> for u8"],["impl From<RecvError> for RecvError"],["impl From<SendError> for ConnectError"],["impl From<SendError> for RecvError"],["impl From<u8> for FrameType"],["impl From<Error> for DialError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<NodeAddr> for NodeData"],["impl From<NodeAddr> for NodeInfo"],["impl From<RelayUrl> for RelayMap"],["impl From<RelayUrl> for RelayNode"],["impl From<NodeInfo> for NodeAddr"],["impl From<RelayNode> for RelayMap"],["impl From<ConnectError> for Error"],["impl From<ConnectionError> for Error"],["impl From<Elapsed> for DialError"],["impl From<Elapsed> for DnsError"],["impl From<Elapsed> for RecvError"],["impl From<Elapsed> for SendError"],["impl From<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for RecvError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<JoinError> for SupervisorError"],["impl From<NoInitialCipherSuite> for Error"],["impl From<RecvError> for Error"],["impl From<ResolveError> for DnsError"],["impl From<Resolver<GenericConnector<TokioRuntimeProvider>>> for DnsResolver"],["impl From<SignedPacketBuildError> for EncodingError"],["impl From<TxtLookup> for TxtLookup"]]]]); if (window.register_implementors) { window.register_implementors(implementors); } else { window.pending_implementors = implementors; } })() -//{"start":57,"fragment_lengths":[6244,4651,13283]} \ No newline at end of file +//{"start":57,"fragment_lengths":[6244,4651,13893]} \ No newline at end of file diff --git a/pr/3355/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js b/pr/3355/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js index d104c409e3..8cd585bc9e 100644 --- a/pr/3355/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js +++ b/pr/3355/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js @@ -1,9 +1,9 @@ (function() { - var implementors = Object.fromEntries([["iroh_relay",[["impl FromIterator<RelayNode> for RelayMap"],["impl FromIterator<RelayUrl> for RelayMap"]]]]); + var implementors = Object.fromEntries([["iroh_relay",[["impl FromIterator<RelayUrl> for RelayMap"],["impl FromIterator<RelayNode> for RelayMap"]]]]); if (window.register_implementors) { window.register_implementors(implementors); } else { window.pending_implementors = implementors; } })() -//{"start":57,"fragment_lengths":[776]} \ No newline at end of file +//{"start":57,"fragment_lengths":[898]} \ No newline at end of file