diff --git a/pr/3402/docs/iroh/endpoint/index.html b/pr/3402/docs/iroh/endpoint/index.html index ce5cd3bdec..327268a0b1 100644 --- a/pr/3402/docs/iroh/endpoint/index.html +++ b/pr/3402/docs/iroh/endpoint/index.html @@ -1,4 +1,4 @@ -iroh::endpoint - Rust

Module endpoint

Source
Expand description

The Endpoint allows establishing connections to other iroh nodes.

+iroh::endpoint - Rust

Module endpoint

Source
Expand description

The Endpoint allows establishing connections to other iroh nodes.

The Endpoint is the main API interface to manage a local iroh node. It allows connecting to and accepting connections from other nodes. See the module docs for more details on how iroh connections work.

diff --git a/pr/3402/docs/iroh_relay/client/struct.ClientBuilder.html b/pr/3402/docs/iroh_relay/client/struct.ClientBuilder.html index d5a068b1d2..99f01d872b 100644 --- a/pr/3402/docs/iroh_relay/client/struct.ClientBuilder.html +++ b/pr/3402/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 address_family_selector<S>(self, selector: S) -> Self
where diff --git a/pr/3402/docs/iroh_relay/dns/struct.DnsResolver.html b/pr/3402/docs/iroh_relay/dns/struct.DnsResolver.html index 93762622c7..e49014846f 100644 --- a/pr/3402/docs/iroh_relay/dns/struct.DnsResolver.html +++ b/pr/3402/docs/iroh_relay/dns/struct.DnsResolver.html @@ -68,9 +68,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( @@ -88,10 +88,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/3402/docs/iroh_relay/index.html b/pr/3402/docs/iroh_relay/index.html index 8137c31c6f..c943a336be 100644 --- a/pr/3402/docs/iroh_relay/index.html +++ b/pr/3402/docs/iroh_relay/index.html @@ -25,6 +25,6 @@ Tailscale.

QAD 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/3402/docs/iroh_relay/node_info/index.html b/pr/3402/docs/iroh_relay/node_info/index.html index 48e4910fda..35bc283b6f 100644 --- a/pr/3402/docs/iroh_relay/node_info/index.html +++ b/pr/3402/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/3402/docs/iroh_relay/node_info/struct.NodeData.html b/pr/3402/docs/iroh_relay/node_info/struct.NodeData.html index c41002605a..85c96c5c32 100644 --- a/pr/3402/docs/iroh_relay/node_info/struct.NodeData.html +++ b/pr/3402/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/3402/docs/iroh_relay/node_info/struct.NodeInfo.html b/pr/3402/docs/iroh_relay/node_info/struct.NodeInfo.html index 20c09def8a..17410a5852 100644 --- a/pr/3402/docs/iroh_relay/node_info/struct.NodeInfo.html +++ b/pr/3402/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/3402/docs/iroh_relay/node_info/trait.NodeIdExt.html b/pr/3402/docs/iroh_relay/node_info/trait.NodeIdExt.html index d668a07cef..b4a8808135 100644 --- a/pr/3402/docs/iroh_relay/node_info/trait.NodeIdExt.html +++ b/pr/3402/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/3402/docs/iroh_relay/protos/relay/enum.ClientToRelayMsg.html b/pr/3402/docs/iroh_relay/protos/relay/enum.ClientToRelayMsg.html index 15ae707ce2..c9b2c54b49 100644 --- a/pr/3402/docs/iroh_relay/protos/relay/enum.ClientToRelayMsg.html +++ b/pr/3402/docs/iroh_relay/protos/relay/enum.ClientToRelayMsg.html @@ -2,7 +2,7 @@ Ping([u8; 8]), Pong([u8; 8]), Datagrams { - dst_node_id: NodeId, + dst_node_id: NodeId, datagrams: Datagrams, }, }
    Expand description

    Messages that clients send to relays.

    @@ -11,7 +11,7 @@ other side with a §

    Pong([u8; 8])

    Reply to a RelayToClientMsg::Ping from a server with the payload sent previously in the ping.

    §

    Datagrams

    Request from the client to relay datagrams to given remote node.

    -

    Fields

    §dst_node_id: NodeId

    The remote node to relay to.

    +

    Fields

    §dst_node_id: NodeId

    The remote node to relay to.

    §datagrams: Datagrams

    The datagrams and related metadata to relay.

    Trait Implementations§

    Source§

    impl Clone for ClientToRelayMsg

    Source§

    fn clone(&self) -> ClientToRelayMsg

    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 ClientToRelayMsg

    Source§

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

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

    impl PartialEq for ClientToRelayMsg

    Source§

    fn eq(&self, other: &ClientToRelayMsg) -> 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 Sink<ClientToRelayMsg> 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/3402/docs/iroh_relay/protos/relay/enum.RelayToClientMsg.html b/pr/3402/docs/iroh_relay/protos/relay/enum.RelayToClientMsg.html index 737b3028c1..b4bef14808 100644 --- a/pr/3402/docs/iroh_relay/protos/relay/enum.RelayToClientMsg.html +++ b/pr/3402/docs/iroh_relay/protos/relay/enum.RelayToClientMsg.html @@ -1,9 +1,9 @@ RelayToClientMsg in iroh_relay::protos::relay - Rust

    Enum RelayToClientMsg

    Source
    pub enum RelayToClientMsg {
         Datagrams {
    -        remote_node_id: NodeId,
    +        remote_node_id: NodeId,
             datagrams: Datagrams,
         },
    -    NodeGone(NodeId),
    +    NodeGone(NodeId),
         Health {
             problem: String,
         },
    @@ -15,9 +15,9 @@
         Pong([u8; 8]),
     }
    Expand description

    The messages that a relay sends to clients or the clients receive from the relay.

    Variants§

    §

    Datagrams

    Represents datagrams sent from relays (originally sent to them by another client).

    -

    Fields

    §remote_node_id: NodeId

    The [NodeId] of the original sender.

    +

    Fields

    §remote_node_id: NodeId

    The NodeId of the original sender.

    §datagrams: Datagrams

    The datagrams and related metadata.

    -
    §

    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 relay.

    §

    Health

    A one-way message from relay to client, declaring the connection health state.

    Fields

    §problem: String

    If set, is a description of why the connection is unhealthy.

    diff --git a/pr/3402/docs/iroh_relay/server/enum.AccessConfig.html b/pr/3402/docs/iroh_relay/server/enum.AccessConfig.html index 43980a2b47..e6c5f9bd6f 100644 --- a/pr/3402/docs/iroh_relay/server/enum.AccessConfig.html +++ b/pr/3402/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/3402/docs/iroh_relay/server/struct.Server.html b/pr/3402/docs/iroh_relay/server/struct.Server.html index d4741ff626..0d55909360 100644 --- a/pr/3402/docs/iroh_relay/server/struct.Server.html +++ b/pr/3402/docs/iroh_relay/server/struct.Server.html @@ -17,9 +17,9 @@ case there is an error in the server before it is shut down.

    Source

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

    The socket address the HTTP server is listening on.

    Source

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

    The socket address the QUIC 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/3402/docs/iroh_relay/struct.RelayMap.html b/pr/3402/docs/iroh_relay/struct.RelayMap.html index 5fefac373c..5bfe6e6a73 100644 --- a/pr/3402/docs/iroh_relay/struct.RelayMap.html +++ b/pr/3402/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 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 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/3402/docs/iroh_relay/struct.RelayNode.html b/pr/3402/docs/iroh_relay/struct.RelayNode.html index da53fdcf3b..dca0e955a0 100644 --- a/pr/3402/docs/iroh_relay/struct.RelayNode.html +++ b/pr/3402/docs/iroh_relay/struct.RelayNode.html @@ -1,14 +1,14 @@ RelayNode in iroh_relay - Rust

    Struct RelayNode

    Source
    pub struct RelayNode {
    -    pub url: RelayUrl,
    +    pub url: RelayUrl,
         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.

    §quic: Option<RelayQuicConfig>

    Configuration to speak to the QUIC endpoint on the relay server.

    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/3402/docs/src/iroh/endpoint.rs.html b/pr/3402/docs/src/iroh/endpoint.rs.html index c17a8998ff..853d5a39e2 100644 --- a/pr/3402/docs/src/iroh/endpoint.rs.html +++ b/pr/3402/docs/src/iroh/endpoint.rs.html @@ -2298,896 +2298,897 @@ 2298 let server_secret_key = SecretKey::generate(rand::thread_rng()); 2299 let server_peer_id = server_secret_key.public(); 2300 -2301 let server = { -2302 let relay_map = relay_map.clone(); -2303 tokio::spawn( -2304 async move { -2305 let ep = Endpoint::builder() -2306 .secret_key(server_secret_key) -2307 .alpns(vec![TEST_ALPN.to_vec()]) -2308 .relay_mode(RelayMode::Custom(relay_map)) -2309 .insecure_skip_relay_cert_verify(true) -2310 .bind() -2311 .await?; -2312 info!("accepting connection"); -2313 let incoming = ep.accept().await.e()?; -2314 let conn = incoming.await.e()?; -2315 let mut stream = conn.accept_uni().await.e()?; -2316 let mut buf = [0u8; 5]; -2317 stream.read_exact(&mut buf).await.e()?; -2318 info!("Accepted 1 stream, received {buf:?}. Closing now."); -2319 // close the connection -2320 conn.close(7u8.into(), b"bye"); -2321 -2322 let res = conn.accept_uni().await; -2323 assert_eq!(res.unwrap_err(), quinn::ConnectionError::LocallyClosed); -2324 -2325 let res = stream.read_to_end(10).await; -2326 assert_eq!( -2327 res.unwrap_err(), -2328 quinn::ReadToEndError::Read(quinn::ReadError::ConnectionLost( -2329 quinn::ConnectionError::LocallyClosed -2330 )) -2331 ); -2332 info!("server test completed"); -2333 Ok::<_, Error>(()) -2334 } -2335 .instrument(info_span!("test-server")), -2336 ) -2337 }; -2338 -2339 let client = tokio::spawn( -2340 async move { -2341 let ep = Endpoint::builder() -2342 .alpns(vec![TEST_ALPN.to_vec()]) -2343 .relay_mode(RelayMode::Custom(relay_map)) -2344 .insecure_skip_relay_cert_verify(true) -2345 .bind() -2346 .await?; -2347 info!("client connecting"); -2348 let node_addr = NodeAddr::new(server_peer_id).with_relay_url(relay_url); -2349 let conn = ep.connect(node_addr, TEST_ALPN).await?; -2350 let mut stream = conn.open_uni().await.e()?; -2351 -2352 // First write is accepted by server. We need this bit of synchronisation -2353 // because if the server closes after simply accepting the connection we can -2354 // not be sure our .open_uni() call would succeed as it may already receive -2355 // the error. -2356 stream.write_all(b"hello").await.e()?; -2357 -2358 info!("waiting for closed"); -2359 // Remote now closes the connection, we should see an error sometime soon. -2360 let err = conn.closed().await; -2361 let expected_err = -2362 quinn::ConnectionError::ApplicationClosed(quinn::ApplicationClose { -2363 error_code: 7u8.into(), -2364 reason: b"bye".to_vec().into(), -2365 }); -2366 assert_eq!(err, expected_err); -2367 -2368 info!("opening new - expect it to fail"); -2369 let res = conn.open_uni().await; -2370 assert_eq!(res.unwrap_err(), expected_err); -2371 info!("client test completed"); -2372 Ok::<_, Error>(()) -2373 } -2374 .instrument(info_span!("test-client")), -2375 ); -2376 -2377 let (server, client) = tokio::time::timeout( -2378 Duration::from_secs(30), -2379 n0_future::future::zip(server, client), -2380 ) -2381 .await -2382 .e()?; -2383 server.e()??; -2384 client.e()??; -2385 Ok(()) -2386 } -2387 -2388 /// Test that peers are properly restored -2389 #[tokio::test] -2390 #[traced_test] -2391 async fn restore_peers() -> Result { -2392 let secret_key = SecretKey::generate(rand::thread_rng()); -2393 -2394 /// Create an endpoint for the test. -2395 async fn new_endpoint( -2396 secret_key: SecretKey, -2397 nodes: Option<Vec<NodeAddr>>, -2398 ) -> Result<Endpoint> { -2399 let mut transport_config = quinn::TransportConfig::default(); -2400 transport_config.max_idle_timeout(Some(Duration::from_secs(10).try_into().unwrap())); -2401 -2402 let mut builder = Endpoint::builder() -2403 .secret_key(secret_key.clone()) -2404 .transport_config(transport_config); -2405 if let Some(nodes) = nodes { -2406 builder = builder.known_nodes(nodes); -2407 } -2408 Ok(builder.alpns(vec![TEST_ALPN.to_vec()]).bind().await?) -2409 } -2410 -2411 // create the peer that will be added to the peer map -2412 let peer_id = SecretKey::generate(rand::thread_rng()).public(); -2413 let direct_addr: SocketAddr = -2414 (std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST), 8758u16).into(); -2415 let node_addr = NodeAddr::new(peer_id).with_direct_addresses([direct_addr]); -2416 -2417 info!("setting up first endpoint"); -2418 // first time, create a magic endpoint without peers but a peers file and add addressing -2419 // information for a peer -2420 let endpoint = new_endpoint(secret_key.clone(), None).await?; -2421 assert_eq!(endpoint.remote_info_iter().count(), 0); -2422 endpoint.add_node_addr(node_addr.clone())?; -2423 -2424 // Grab the current addrs -2425 let node_addrs: Vec<NodeAddr> = endpoint.remote_info_iter().map(Into::into).collect(); -2426 assert_eq!(node_addrs.len(), 1); -2427 assert_eq!(node_addrs[0], node_addr); -2428 -2429 info!("closing endpoint"); -2430 // close the endpoint and restart it -2431 endpoint.close().await; -2432 -2433 info!("restarting endpoint"); -2434 // now restart it and check the addressing info of the peer -2435 let endpoint = new_endpoint(secret_key, Some(node_addrs)).await?; -2436 let RemoteInfo { mut addrs, .. } = endpoint.remote_info(peer_id).e()?; -2437 let conn_addr = addrs.pop().unwrap().addr; -2438 assert_eq!(conn_addr, direct_addr); -2439 Ok(()) -2440 } -2441 -2442 #[tokio::test] -2443 #[traced_test] -2444 async fn endpoint_relay_connect_loop() -> Result { -2445 let start = Instant::now(); -2446 let n_clients = 5; -2447 let n_chunks_per_client = 2; -2448 let chunk_size = 10; -2449 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(42); -2450 let (relay_map, relay_url, _relay_guard) = run_relay_server().await.unwrap(); -2451 let server_secret_key = SecretKey::generate(&mut rng); -2452 let server_node_id = server_secret_key.public(); -2453 -2454 // Make sure the server is bound before having clients connect to it: -2455 let ep = Endpoint::builder() -2456 .insecure_skip_relay_cert_verify(true) -2457 .secret_key(server_secret_key) -2458 .alpns(vec![TEST_ALPN.to_vec()]) -2459 .relay_mode(RelayMode::Custom(relay_map.clone())) -2460 .bind() -2461 .await?; -2462 // Also make sure the server has a working relay connection -2463 ep.home_relay().initialized().await?; -2464 // The server accepts the connections of the clients sequentially. -2465 let server = tokio::spawn( -2466 async move { -2467 let eps = ep.bound_sockets(); -2468 -2469 info!(me = %ep.node_id().fmt_short(), eps = ?eps, "server listening on"); -2470 for i in 0..n_clients { -2471 let round_start = Instant::now(); -2472 info!("[server] round {i}"); -2473 let incoming = ep.accept().await.e()?; -2474 let conn = incoming.await.e()?; -2475 let node_id = conn.remote_node_id()?; -2476 info!(%i, peer = %node_id.fmt_short(), "accepted connection"); -2477 let (mut send, mut recv) = conn.accept_bi().await.e()?; -2478 let mut buf = vec![0u8; chunk_size]; -2479 for _i in 0..n_chunks_per_client { -2480 recv.read_exact(&mut buf).await.e()?; -2481 send.write_all(&buf).await.e()?; -2482 } -2483 send.finish().e()?; -2484 send.stopped().await.e()?; -2485 recv.read_to_end(0).await.e()?; -2486 info!(%i, peer = %node_id.fmt_short(), "finished"); -2487 info!("[server] round {i} done in {:?}", round_start.elapsed()); -2488 } -2489 Ok::<_, Error>(()) -2490 } -2491 .instrument(error_span!("server")), -2492 ); -2493 -2494 for i in 0..n_clients { -2495 let round_start = Instant::now(); -2496 info!("[client] round {}", i); -2497 let client_secret_key = SecretKey::generate(&mut rng); -2498 async { -2499 info!("client binding"); -2500 let ep = Endpoint::builder() -2501 .alpns(vec![TEST_ALPN.to_vec()]) -2502 .insecure_skip_relay_cert_verify(true) -2503 .relay_mode(RelayMode::Custom(relay_map.clone())) -2504 .secret_key(client_secret_key) -2505 .bind() -2506 .await?; -2507 let eps = ep.bound_sockets(); -2508 -2509 info!(me = %ep.node_id().fmt_short(), eps=?eps, "client bound"); -2510 let node_addr = NodeAddr::new(server_node_id).with_relay_url(relay_url.clone()); -2511 info!(to = ?node_addr, "client connecting"); -2512 let conn = ep.connect(node_addr, TEST_ALPN).await.e()?; -2513 info!("client connected"); -2514 let (mut send, mut recv) = conn.open_bi().await.e()?; -2515 -2516 for i in 0..n_chunks_per_client { -2517 let mut buf = vec![i; chunk_size]; -2518 send.write_all(&buf).await.e()?; -2519 recv.read_exact(&mut buf).await.e()?; -2520 assert_eq!(buf, vec![i; chunk_size]); -2521 } -2522 send.finish().e()?; -2523 send.stopped().await.e()?; -2524 recv.read_to_end(0).await.e()?; -2525 info!("client finished"); -2526 ep.close().await; -2527 info!("client closed"); -2528 Ok::<_, Error>(()) -2529 } -2530 .instrument(error_span!("client", %i)) -2531 .await?; -2532 info!("[client] round {i} done in {:?}", round_start.elapsed()); -2533 } -2534 -2535 server.await.e()??; -2536 -2537 // We appear to have seen this being very slow at times. So ensure we fail if this -2538 // test is too slow. We're only making two connections transferring very little -2539 // data, this really shouldn't take long. -2540 if start.elapsed() > Duration::from_secs(15) { -2541 panic!("Test too slow, something went wrong"); -2542 } -2543 -2544 Ok(()) -2545 } -2546 -2547 #[tokio::test] -2548 #[traced_test] -2549 async fn endpoint_send_relay() -> Result { -2550 let (relay_map, _relay_url, _guard) = run_relay_server().await?; -2551 let client = Endpoint::builder() -2552 .insecure_skip_relay_cert_verify(true) -2553 .relay_mode(RelayMode::Custom(relay_map.clone())) -2554 .bind() -2555 .await?; -2556 let server = Endpoint::builder() -2557 .insecure_skip_relay_cert_verify(true) -2558 .relay_mode(RelayMode::Custom(relay_map)) -2559 .alpns(vec![TEST_ALPN.to_vec()]) -2560 .bind() -2561 .await?; -2562 -2563 let task = tokio::spawn({ -2564 let server = server.clone(); -2565 async move { -2566 let Some(conn) = server.accept().await else { -2567 snafu::whatever!("Expected an incoming connection"); -2568 }; -2569 let conn = conn.await.e()?; -2570 let (mut send, mut recv) = conn.accept_bi().await.e()?; -2571 let data = recv.read_to_end(1000).await.e()?; -2572 send.write_all(&data).await.e()?; -2573 send.finish().e()?; -2574 conn.closed().await; -2575 -2576 Ok::<_, Error>(()) -2577 } -2578 }); -2579 -2580 let addr = server.node_addr().initialized().await?; -2581 let conn = client.connect(addr, TEST_ALPN).await?; -2582 let (mut send, mut recv) = conn.open_bi().await.e()?; -2583 send.write_all(b"Hello, world!").await.e()?; -2584 send.finish().e()?; -2585 let data = recv.read_to_end(1000).await.e()?; -2586 conn.close(0u32.into(), b"bye!"); -2587 -2588 task.await.e()??; -2589 -2590 client.close().await; -2591 server.close().await; -2592 -2593 assert_eq!(&data, b"Hello, world!"); -2594 -2595 Ok(()) -2596 } -2597 -2598 #[tokio::test] -2599 #[traced_test] -2600 async fn endpoint_bidi_send_recv() -> Result { -2601 let ep1 = Endpoint::builder() -2602 .alpns(vec![TEST_ALPN.to_vec()]) -2603 .relay_mode(RelayMode::Disabled); -2604 -2605 let ep1 = ep1.bind().await?; -2606 let ep2 = Endpoint::builder() -2607 .alpns(vec![TEST_ALPN.to_vec()]) -2608 .relay_mode(RelayMode::Disabled); -2609 -2610 let ep2 = ep2.bind().await?; -2611 -2612 let ep1_nodeaddr = ep1.node_addr().initialized().await?; -2613 let ep2_nodeaddr = ep2.node_addr().initialized().await?; -2614 ep1.add_node_addr(ep2_nodeaddr.clone())?; -2615 ep2.add_node_addr(ep1_nodeaddr.clone())?; -2616 let ep1_nodeid = ep1.node_id(); -2617 let ep2_nodeid = ep2.node_id(); -2618 eprintln!("node id 1 {ep1_nodeid}"); -2619 eprintln!("node id 2 {ep2_nodeid}"); -2620 -2621 async fn connect_hello(ep: Endpoint, dst: NodeAddr) -> Result { -2622 let conn = ep.connect(dst, TEST_ALPN).await?; -2623 let (mut send, mut recv) = conn.open_bi().await.e()?; -2624 info!("sending hello"); -2625 send.write_all(b"hello").await.e()?; -2626 send.finish().e()?; -2627 info!("receiving world"); -2628 let m = recv.read_to_end(100).await.e()?; -2629 assert_eq!(m, b"world"); -2630 conn.close(1u8.into(), b"done"); -2631 Ok(()) -2632 } -2633 -2634 async fn accept_world(ep: Endpoint, src: NodeId) -> Result { -2635 let incoming = ep.accept().await.e()?; -2636 let mut iconn = incoming.accept().e()?; -2637 let alpn = iconn.alpn().await?; -2638 let conn = iconn.await.e()?; -2639 let node_id = conn.remote_node_id()?; -2640 assert_eq!(node_id, src); -2641 assert_eq!(alpn, TEST_ALPN); -2642 let (mut send, mut recv) = conn.accept_bi().await.e()?; -2643 info!("receiving hello"); -2644 let m = recv.read_to_end(100).await.e()?; -2645 assert_eq!(m, b"hello"); -2646 info!("sending hello"); -2647 send.write_all(b"world").await.e()?; -2648 send.finish().e()?; -2649 match conn.closed().await { -2650 ConnectionError::ApplicationClosed(closed) => { -2651 assert_eq!(closed.error_code, 1u8.into()); -2652 Ok(()) -2653 } -2654 _ => panic!("wrong close error"), -2655 } -2656 } -2657 -2658 let p1_accept = tokio::spawn(accept_world(ep1.clone(), ep2_nodeid).instrument(info_span!( -2659 "p1_accept", -2660 ep1 = %ep1.node_id().fmt_short(), -2661 dst = %ep2_nodeid.fmt_short(), -2662 ))); -2663 let p2_accept = tokio::spawn(accept_world(ep2.clone(), ep1_nodeid).instrument(info_span!( -2664 "p2_accept", -2665 ep2 = %ep2.node_id().fmt_short(), -2666 dst = %ep1_nodeid.fmt_short(), -2667 ))); -2668 let p1_connect = tokio::spawn(connect_hello(ep1.clone(), ep2_nodeaddr).instrument( -2669 info_span!( -2670 "p1_connect", -2671 ep1 = %ep1.node_id().fmt_short(), -2672 dst = %ep2_nodeid.fmt_short(), -2673 ), -2674 )); -2675 let p2_connect = tokio::spawn(connect_hello(ep2.clone(), ep1_nodeaddr).instrument( -2676 info_span!( -2677 "p2_connect", -2678 ep2 = %ep2.node_id().fmt_short(), -2679 dst = %ep1_nodeid.fmt_short(), -2680 ), -2681 )); -2682 -2683 p1_accept.await.e()??; -2684 p2_accept.await.e()??; -2685 p1_connect.await.e()??; -2686 p2_connect.await.e()??; -2687 -2688 Ok(()) -2689 } -2690 -2691 #[tokio::test] -2692 #[traced_test] -2693 async fn endpoint_conn_type_becomes_direct() -> Result { -2694 const TIMEOUT: Duration = std::time::Duration::from_secs(15); -2695 let (relay_map, _relay_url, _relay_guard) = run_relay_server().await?; -2696 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(42); -2697 let ep1_secret_key = SecretKey::generate(&mut rng); -2698 let ep2_secret_key = SecretKey::generate(&mut rng); -2699 let ep1 = Endpoint::builder() -2700 .secret_key(ep1_secret_key) -2701 .insecure_skip_relay_cert_verify(true) -2702 .alpns(vec![TEST_ALPN.to_vec()]) -2703 .relay_mode(RelayMode::Custom(relay_map.clone())) -2704 .bind() -2705 .await?; -2706 let ep2 = Endpoint::builder() -2707 .secret_key(ep2_secret_key) -2708 .insecure_skip_relay_cert_verify(true) -2709 .alpns(vec![TEST_ALPN.to_vec()]) -2710 .relay_mode(RelayMode::Custom(relay_map)) -2711 .bind() -2712 .await?; -2713 -2714 async fn wait_for_conn_type_direct(ep: &Endpoint, node_id: NodeId) -> Result { -2715 let mut stream = ep.conn_type(node_id).expect("connection exists").stream(); -2716 let src = ep.node_id().fmt_short(); -2717 let dst = node_id.fmt_short(); -2718 while let Some(conn_type) = stream.next().await { -2719 tracing::info!(me = %src, dst = %dst, conn_type = ?conn_type); -2720 if matches!(conn_type, ConnectionType::Direct(_)) { -2721 return Ok(()); -2722 } -2723 } -2724 snafu::whatever!("conn_type stream ended before `ConnectionType::Direct`"); -2725 } -2726 -2727 async fn accept(ep: &Endpoint) -> Result<Connection> { -2728 let incoming = ep.accept().await.expect("ep closed"); -2729 let conn = incoming.await.e()?; -2730 let node_id = conn.remote_node_id()?; -2731 tracing::info!(node_id=%node_id.fmt_short(), "accepted connection"); -2732 Ok(conn) -2733 } -2734 -2735 let ep1_nodeid = ep1.node_id(); -2736 let ep2_nodeid = ep2.node_id(); -2737 -2738 let ep1_nodeaddr = ep1.node_addr().initialized().await?; -2739 tracing::info!( -2740 "node id 1 {ep1_nodeid}, relay URL {:?}", -2741 ep1_nodeaddr.relay_url() -2742 ); -2743 tracing::info!("node id 2 {ep2_nodeid}"); -2744 -2745 let ep1_side = tokio::time::timeout(TIMEOUT, async move { -2746 let conn = accept(&ep1).await?; -2747 let mut send = conn.open_uni().await.e()?; -2748 wait_for_conn_type_direct(&ep1, ep2_nodeid).await?; -2749 send.write_all(b"Conn is direct").await.e()?; -2750 send.finish().e()?; -2751 conn.closed().await; -2752 Ok::<(), Error>(()) -2753 }); -2754 -2755 let ep2_side = tokio::time::timeout(TIMEOUT, async move { -2756 let conn = ep2.connect(ep1_nodeaddr, TEST_ALPN).await?; -2757 let mut recv = conn.accept_uni().await.e()?; -2758 wait_for_conn_type_direct(&ep2, ep1_nodeid).await?; -2759 let read = recv.read_to_end(100).await.e()?; -2760 assert_eq!(read, b"Conn is direct".to_vec()); -2761 conn.close(0u32.into(), b"done"); -2762 conn.closed().await; -2763 Ok::<(), Error>(()) -2764 }); -2765 -2766 let res_ep1 = AbortOnDropHandle::new(tokio::spawn(ep1_side)); -2767 let res_ep2 = AbortOnDropHandle::new(tokio::spawn(ep2_side)); -2768 -2769 let (r1, r2) = tokio::try_join!(res_ep1, res_ep2).e()?; -2770 r1.e()??; -2771 r2.e()??; -2772 -2773 Ok(()) -2774 } -2775 -2776 #[tokio::test] -2777 #[traced_test] -2778 async fn test_direct_addresses_no_qad_relay() -> Result { -2779 let (relay_map, _, _guard) = run_relay_server_with(false).await.unwrap(); -2780 -2781 let ep = Endpoint::builder() -2782 .alpns(vec![TEST_ALPN.to_vec()]) -2783 .relay_mode(RelayMode::Custom(relay_map)) -2784 .insecure_skip_relay_cert_verify(true) -2785 .bind() -2786 .await?; -2787 -2788 tokio::time::timeout(Duration::from_secs(10), ep.direct_addresses().initialized()) -2789 .await -2790 .e()??; -2791 Ok(()) -2792 } -2793 -2794 async fn spawn_0rtt_server(secret_key: SecretKey, log_span: tracing::Span) -> Result<Endpoint> { -2795 let server = Endpoint::builder() -2796 .secret_key(secret_key) -2797 .alpns(vec![TEST_ALPN.to_vec()]) -2798 .relay_mode(RelayMode::Disabled) -2799 .bind() -2800 .await?; -2801 -2802 // Gets aborted via the endpoint closing causing an `Err` -2803 // a simple echo server -2804 tokio::spawn({ -2805 let server = server.clone(); -2806 async move { -2807 while let Some(incoming) = server.accept().await { -2808 let connecting = incoming.accept().e()?; -2809 let conn = match connecting.into_0rtt() { -2810 Ok((conn, _)) => { -2811 info!("0rtt accepted"); -2812 conn -2813 } -2814 Err(connecting) => { -2815 info!("0rtt denied"); -2816 connecting.await.e()? -2817 } -2818 }; -2819 let (mut send, mut recv) = conn.accept_bi().await.e()?; -2820 let data = recv.read_to_end(10_000_000).await.e()?; -2821 send.write_all(&data).await.e()?; -2822 send.finish().e()?; -2823 -2824 // Stay alive until the other side closes the connection. -2825 conn.closed().await; -2826 } -2827 Ok::<_, Error>(()) -2828 } -2829 .instrument(log_span) -2830 }); -2831 -2832 Ok(server) -2833 } -2834 -2835 async fn connect_client_0rtt_expect_err(client: &Endpoint, server_addr: NodeAddr) -> Result { -2836 let conn = client -2837 .connect_with_opts(server_addr, TEST_ALPN, ConnectOptions::new()) -2838 .await? -2839 .into_0rtt() -2840 .expect_err("expected 0rtt to fail") -2841 .await -2842 .e()?; -2843 -2844 let (mut send, mut recv) = conn.open_bi().await.e()?; -2845 send.write_all(b"hello").await.e()?; -2846 send.finish().e()?; -2847 let received = recv.read_to_end(1_000).await.e()?; -2848 assert_eq!(&received, b"hello"); -2849 conn.close(0u32.into(), b"thx"); -2850 Ok(()) -2851 } -2852 -2853 async fn connect_client_0rtt_expect_ok( -2854 client: &Endpoint, -2855 server_addr: NodeAddr, -2856 expect_server_accepts: bool, -2857 ) -> Result { -2858 let (conn, accepted_0rtt) = client -2859 .connect_with_opts(server_addr, TEST_ALPN, ConnectOptions::new()) -2860 .await? -2861 .into_0rtt() -2862 .ok() -2863 .e()?; -2864 -2865 // This is how we send data in 0-RTT: -2866 let (mut send, recv) = conn.open_bi().await.e()?; -2867 send.write_all(b"hello").await.e()?; -2868 send.finish().e()?; -2869 // When this resolves, we've gotten a response from the server about whether the 0-RTT data above was accepted: -2870 let accepted = accepted_0rtt.await; -2871 assert_eq!(accepted, expect_server_accepts); -2872 let mut recv = if accepted { -2873 recv -2874 } else { -2875 // in this case we need to re-send data by re-creating the connection. -2876 let (mut send, recv) = conn.open_bi().await.e()?; -2877 send.write_all(b"hello").await.e()?; -2878 send.finish().e()?; -2879 recv -2880 }; -2881 let received = recv.read_to_end(1_000).await.e()?; -2882 assert_eq!(&received, b"hello"); -2883 conn.close(0u32.into(), b"thx"); -2884 Ok(()) -2885 } -2886 -2887 #[tokio::test] -2888 #[traced_test] -2889 async fn test_0rtt() -> Result { -2890 let client = Endpoint::builder() -2891 .relay_mode(RelayMode::Disabled) -2892 .bind() -2893 .await?; -2894 let server = spawn_0rtt_server( -2895 SecretKey::generate(rand::thread_rng()), -2896 info_span!("server"), -2897 ) -2898 .await?; -2899 -2900 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; -2901 // The second 0rtt attempt should work -2902 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) -2903 .await?; -2904 -2905 client.close().await; -2906 server.close().await; -2907 -2908 Ok(()) -2909 } -2910 -2911 // We have this test, as this would've failed at some point. -2912 // This effectively tests that we correctly categorize the TLS session tickets we -2913 // receive into the respective "bucket" for the recipient. -2914 #[tokio::test] -2915 #[traced_test] -2916 async fn test_0rtt_non_consecutive() -> Result { -2917 let client = Endpoint::builder() -2918 .relay_mode(RelayMode::Disabled) -2919 .bind() -2920 .await?; -2921 let server = spawn_0rtt_server( -2922 SecretKey::generate(rand::thread_rng()), -2923 info_span!("server"), -2924 ) -2925 .await?; -2926 -2927 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; -2928 -2929 // connecting with another endpoint should not interfere with our -2930 // TLS session ticket cache for the first endpoint: -2931 let another = spawn_0rtt_server( -2932 SecretKey::generate(rand::thread_rng()), -2933 info_span!("another"), -2934 ) -2935 .await?; -2936 connect_client_0rtt_expect_err(&client, another.node_addr().initialized().await?).await?; -2937 another.close().await; -2938 -2939 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) -2940 .await?; -2941 -2942 client.close().await; -2943 server.close().await; -2944 -2945 Ok(()) -2946 } -2947 -2948 // Test whether 0-RTT is possible after a restart: -2949 #[tokio::test] -2950 #[traced_test] -2951 async fn test_0rtt_after_server_restart() -> Result { -2952 let client = Endpoint::builder() -2953 .relay_mode(RelayMode::Disabled) -2954 .bind() -2955 .await?; -2956 let server_key = SecretKey::generate(rand::thread_rng()); -2957 let server = spawn_0rtt_server(server_key.clone(), info_span!("server-initial")).await?; -2958 -2959 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; -2960 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) -2961 .await?; -2962 -2963 server.close().await; -2964 -2965 let server = spawn_0rtt_server(server_key, info_span!("server-restart")).await?; -2966 -2967 // we expect the client to *believe* it can 0-RTT connect to the server (hence expect_ok), -2968 // but the server will reject the early data because it discarded necessary state -2969 // to decrypt it when restarting. -2970 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, false) -2971 .await?; -2972 -2973 client.close().await; -2974 -2975 Ok(()) -2976 } -2977 -2978 #[cfg_attr(target_os = "windows", ignore = "flaky")] -2979 #[tokio::test] -2980 #[traced_test] -2981 async fn graceful_close() -> Result { -2982 let client = Endpoint::builder().bind().await?; -2983 let server = Endpoint::builder() -2984 .alpns(vec![TEST_ALPN.to_vec()]) -2985 .bind() -2986 .await?; -2987 let server_addr = server.node_addr().initialized().await?; -2988 let server_task = tokio::spawn(async move { -2989 let incoming = server.accept().await.e()?; -2990 let conn = incoming.await.e()?; -2991 let (mut send, mut recv) = conn.accept_bi().await.e()?; -2992 let msg = recv.read_to_end(1_000).await.e()?; -2993 send.write_all(&msg).await.e()?; -2994 send.finish().e()?; -2995 let close_reason = conn.closed().await; -2996 Ok::<_, Error>(close_reason) -2997 }); -2998 -2999 let conn = client.connect(server_addr, TEST_ALPN).await?; -3000 let (mut send, mut recv) = conn.open_bi().await.e()?; -3001 send.write_all(b"Hello, world!").await.e()?; -3002 send.finish().e()?; -3003 recv.read_to_end(1_000).await.e()?; -3004 conn.close(42u32.into(), b"thanks, bye!"); -3005 client.close().await; -3006 -3007 let close_err = server_task.await.e()??; -3008 let ConnectionError::ApplicationClosed(app_close) = close_err else { -3009 panic!("Unexpected close reason: {close_err:?}"); -3010 }; -3011 -3012 assert_eq!(app_close.error_code, 42u32.into()); -3013 assert_eq!(app_close.reason.as_ref(), b"thanks, bye!"); -3014 -3015 Ok(()) -3016 } -3017 -3018 #[cfg(feature = "metrics")] -3019 #[tokio::test] -3020 #[traced_test] -3021 async fn metrics_smoke() -> Result { -3022 use iroh_metrics::{MetricsSource, Registry}; -3023 -3024 let secret_key = SecretKey::from_bytes(&[0u8; 32]); -3025 let client = Endpoint::builder() -3026 .secret_key(secret_key) -3027 .relay_mode(RelayMode::Disabled) -3028 .bind() -3029 .await?; -3030 let secret_key = SecretKey::from_bytes(&[1u8; 32]); -3031 let server = Endpoint::builder() -3032 .secret_key(secret_key) -3033 .relay_mode(RelayMode::Disabled) -3034 .alpns(vec![TEST_ALPN.to_vec()]) -3035 .bind() -3036 .await?; -3037 let server_addr = server.node_addr().initialized().await?; -3038 let server_task = tokio::task::spawn(async move { -3039 let conn = server.accept().await.e()?.accept().e()?.await.e()?; -3040 let mut uni = conn.accept_uni().await.e()?; -3041 uni.read_to_end(10).await.e()?; -3042 drop(conn); -3043 Ok::<_, Error>(server) -3044 }); -3045 let conn = client.connect(server_addr, TEST_ALPN).await?; -3046 let mut uni = conn.open_uni().await.e()?; -3047 uni.write_all(b"helloworld").await.e()?; -3048 uni.finish().e()?; -3049 conn.closed().await; -3050 drop(conn); -3051 let server = server_task.await.e()??; -3052 -3053 let m = client.metrics(); -3054 assert_eq!(m.magicsock.num_direct_conns_added.get(), 1); -3055 assert_eq!(m.magicsock.connection_became_direct.get(), 1); -3056 assert_eq!(m.magicsock.connection_handshake_success.get(), 1); -3057 assert_eq!(m.magicsock.nodes_contacted_directly.get(), 1); -3058 assert!(m.magicsock.recv_datagrams.get() > 0); -3059 -3060 let m = server.metrics(); -3061 assert_eq!(m.magicsock.num_direct_conns_added.get(), 1); -3062 assert_eq!(m.magicsock.connection_became_direct.get(), 1); -3063 assert_eq!(m.magicsock.nodes_contacted_directly.get(), 1); -3064 assert_eq!(m.magicsock.connection_handshake_success.get(), 1); -3065 assert!(m.magicsock.recv_datagrams.get() > 0); -3066 -3067 // test openmetrics encoding with labeled subregistries per endpoint -3068 fn register_endpoint(registry: &mut Registry, endpoint: &Endpoint) { -3069 let id = endpoint.node_id().fmt_short(); -3070 let sub_registry = registry.sub_registry_with_label("id", id); -3071 sub_registry.register_all(endpoint.metrics()); -3072 } -3073 let mut registry = Registry::default(); -3074 register_endpoint(&mut registry, &client); -3075 register_endpoint(&mut registry, &server); -3076 let s = registry.encode_openmetrics_to_string()?; -3077 assert!(s.contains(r#"magicsock_nodes_contacted_directly_total{id="3b6a27bcce"} 1"#)); -3078 assert!(s.contains(r#"magicsock_nodes_contacted_directly_total{id="8a88e3dd74"} 1"#)); -3079 Ok(()) -3080 } -3081 -3082 /// Configures the accept side to take `accept_alpns` ALPNs, then connects to it with `primary_connect_alpn` -3083 /// with `secondary_connect_alpns` set, and finally returns the negotiated ALPN. -3084 async fn alpn_connection_test( -3085 accept_alpns: Vec<Vec<u8>>, -3086 primary_connect_alpn: &[u8], -3087 secondary_connect_alpns: Vec<Vec<u8>>, -3088 ) -> Result<Option<Vec<u8>>> { -3089 let client = Endpoint::builder() -3090 .relay_mode(RelayMode::Disabled) -3091 .bind() -3092 .await?; -3093 let server = Endpoint::builder() -3094 .relay_mode(RelayMode::Disabled) -3095 .alpns(accept_alpns) -3096 .bind() -3097 .await?; -3098 let server_addr = server.node_addr().initialized().await?; -3099 let server_task = tokio::spawn({ -3100 let server = server.clone(); -3101 async move { -3102 let incoming = server.accept().await.e()?; -3103 let conn = incoming.await.e()?; -3104 conn.close(0u32.into(), b"bye!"); -3105 Ok::<_, n0_snafu::Error>(conn.alpn()) -3106 } -3107 }); -3108 -3109 let conn = client -3110 .connect_with_opts( -3111 server_addr, -3112 primary_connect_alpn, -3113 ConnectOptions::new().with_additional_alpns(secondary_connect_alpns), -3114 ) -3115 .await?; -3116 let conn = conn.await.e()?; -3117 let client_alpn = conn.alpn(); -3118 conn.closed().await; -3119 client.close().await; -3120 server.close().await; -3121 -3122 let server_alpn = server_task.await.e()??; -3123 -3124 assert_eq!(client_alpn, server_alpn); -3125 -3126 Ok(server_alpn) -3127 } -3128 -3129 #[tokio::test] -3130 #[traced_test] -3131 async fn connect_multiple_alpn_negotiated() -> Result { -3132 const ALPN_ONE: &[u8] = b"alpn/1"; -3133 const ALPN_TWO: &[u8] = b"alpn/2"; -3134 -3135 assert_eq!( -3136 alpn_connection_test( -3137 // Prefer version 2 over version 1 on the accept side -3138 vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], -3139 ALPN_TWO, -3140 vec![ALPN_ONE.to_vec()], -3141 ) -3142 .await?, -3143 Some(ALPN_TWO.to_vec()), -3144 "accept side prefers version 2 over 1" -3145 ); -3146 -3147 assert_eq!( -3148 alpn_connection_test( -3149 // Only support the old version -3150 vec![ALPN_ONE.to_vec()], -3151 ALPN_TWO, -3152 vec![ALPN_ONE.to_vec()], -3153 ) -3154 .await?, -3155 Some(ALPN_ONE.to_vec()), -3156 "accept side only supports the old version" -3157 ); -3158 -3159 assert_eq!( -3160 alpn_connection_test( -3161 vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], -3162 ALPN_ONE, -3163 vec![ALPN_TWO.to_vec()], -3164 ) -3165 .await?, -3166 Some(ALPN_TWO.to_vec()), -3167 "connect side ALPN order doesn't matter" -3168 ); -3169 -3170 assert_eq!( -3171 alpn_connection_test(vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], ALPN_ONE, vec![],) -3172 .await?, -3173 Some(ALPN_ONE.to_vec()), -3174 "connect side only supports the old version" -3175 ); -3176 -3177 Ok(()) -3178 } -3179 -3180 #[tokio::test] -3181 #[traced_test] -3182 async fn watch_net_report() -> Result { -3183 let endpoint = Endpoint::builder() -3184 .relay_mode(RelayMode::Staging) -3185 .bind() -3186 .await?; -3187 -3188 // can get a first report -3189 endpoint.net_report().updated().await?; -3190 -3191 Ok(()) -3192 } -3193}
    \ No newline at end of file +2301 // Wait for the endpoint to be started to make sure it's up before clients try to connect +2302 let ep = Endpoint::builder() +2303 .secret_key(server_secret_key) +2304 .alpns(vec![TEST_ALPN.to_vec()]) +2305 .relay_mode(RelayMode::Custom(relay_map.clone())) +2306 .insecure_skip_relay_cert_verify(true) +2307 .bind() +2308 .await?; +2309 // Wait for the endpoint to be reachable via relay +2310 ep.home_relay().initialized().await?; +2311 +2312 let server = tokio::spawn( +2313 async move { +2314 info!("accepting connection"); +2315 let incoming = ep.accept().await.e()?; +2316 let conn = incoming.await.e()?; +2317 let mut stream = conn.accept_uni().await.e()?; +2318 let mut buf = [0u8; 5]; +2319 stream.read_exact(&mut buf).await.e()?; +2320 info!("Accepted 1 stream, received {buf:?}. Closing now."); +2321 // close the connection +2322 conn.close(7u8.into(), b"bye"); +2323 +2324 let res = conn.accept_uni().await; +2325 assert_eq!(res.unwrap_err(), quinn::ConnectionError::LocallyClosed); +2326 +2327 let res = stream.read_to_end(10).await; +2328 assert_eq!( +2329 res.unwrap_err(), +2330 quinn::ReadToEndError::Read(quinn::ReadError::ConnectionLost( +2331 quinn::ConnectionError::LocallyClosed +2332 )) +2333 ); +2334 info!("server test completed"); +2335 Ok::<_, Error>(()) +2336 } +2337 .instrument(info_span!("test-server")), +2338 ); +2339 +2340 let client = tokio::spawn( +2341 async move { +2342 let ep = Endpoint::builder() +2343 .alpns(vec![TEST_ALPN.to_vec()]) +2344 .relay_mode(RelayMode::Custom(relay_map)) +2345 .insecure_skip_relay_cert_verify(true) +2346 .bind() +2347 .await?; +2348 info!("client connecting"); +2349 let node_addr = NodeAddr::new(server_peer_id).with_relay_url(relay_url); +2350 let conn = ep.connect(node_addr, TEST_ALPN).await?; +2351 let mut stream = conn.open_uni().await.e()?; +2352 +2353 // First write is accepted by server. We need this bit of synchronisation +2354 // because if the server closes after simply accepting the connection we can +2355 // not be sure our .open_uni() call would succeed as it may already receive +2356 // the error. +2357 stream.write_all(b"hello").await.e()?; +2358 +2359 info!("waiting for closed"); +2360 // Remote now closes the connection, we should see an error sometime soon. +2361 let err = conn.closed().await; +2362 let expected_err = +2363 quinn::ConnectionError::ApplicationClosed(quinn::ApplicationClose { +2364 error_code: 7u8.into(), +2365 reason: b"bye".to_vec().into(), +2366 }); +2367 assert_eq!(err, expected_err); +2368 +2369 info!("opening new - expect it to fail"); +2370 let res = conn.open_uni().await; +2371 assert_eq!(res.unwrap_err(), expected_err); +2372 info!("client test completed"); +2373 Ok::<_, Error>(()) +2374 } +2375 .instrument(info_span!("test-client")), +2376 ); +2377 +2378 let (server, client) = tokio::time::timeout( +2379 Duration::from_secs(30), +2380 n0_future::future::zip(server, client), +2381 ) +2382 .await +2383 .e()?; +2384 server.e()??; +2385 client.e()??; +2386 Ok(()) +2387 } +2388 +2389 /// Test that peers are properly restored +2390 #[tokio::test] +2391 #[traced_test] +2392 async fn restore_peers() -> Result { +2393 let secret_key = SecretKey::generate(rand::thread_rng()); +2394 +2395 /// Create an endpoint for the test. +2396 async fn new_endpoint( +2397 secret_key: SecretKey, +2398 nodes: Option<Vec<NodeAddr>>, +2399 ) -> Result<Endpoint> { +2400 let mut transport_config = quinn::TransportConfig::default(); +2401 transport_config.max_idle_timeout(Some(Duration::from_secs(10).try_into().unwrap())); +2402 +2403 let mut builder = Endpoint::builder() +2404 .secret_key(secret_key.clone()) +2405 .transport_config(transport_config); +2406 if let Some(nodes) = nodes { +2407 builder = builder.known_nodes(nodes); +2408 } +2409 Ok(builder.alpns(vec![TEST_ALPN.to_vec()]).bind().await?) +2410 } +2411 +2412 // create the peer that will be added to the peer map +2413 let peer_id = SecretKey::generate(rand::thread_rng()).public(); +2414 let direct_addr: SocketAddr = +2415 (std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST), 8758u16).into(); +2416 let node_addr = NodeAddr::new(peer_id).with_direct_addresses([direct_addr]); +2417 +2418 info!("setting up first endpoint"); +2419 // first time, create a magic endpoint without peers but a peers file and add addressing +2420 // information for a peer +2421 let endpoint = new_endpoint(secret_key.clone(), None).await?; +2422 assert_eq!(endpoint.remote_info_iter().count(), 0); +2423 endpoint.add_node_addr(node_addr.clone())?; +2424 +2425 // Grab the current addrs +2426 let node_addrs: Vec<NodeAddr> = endpoint.remote_info_iter().map(Into::into).collect(); +2427 assert_eq!(node_addrs.len(), 1); +2428 assert_eq!(node_addrs[0], node_addr); +2429 +2430 info!("closing endpoint"); +2431 // close the endpoint and restart it +2432 endpoint.close().await; +2433 +2434 info!("restarting endpoint"); +2435 // now restart it and check the addressing info of the peer +2436 let endpoint = new_endpoint(secret_key, Some(node_addrs)).await?; +2437 let RemoteInfo { mut addrs, .. } = endpoint.remote_info(peer_id).e()?; +2438 let conn_addr = addrs.pop().unwrap().addr; +2439 assert_eq!(conn_addr, direct_addr); +2440 Ok(()) +2441 } +2442 +2443 #[tokio::test] +2444 #[traced_test] +2445 async fn endpoint_relay_connect_loop() -> Result { +2446 let start = Instant::now(); +2447 let n_clients = 5; +2448 let n_chunks_per_client = 2; +2449 let chunk_size = 10; +2450 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(42); +2451 let (relay_map, relay_url, _relay_guard) = run_relay_server().await.unwrap(); +2452 let server_secret_key = SecretKey::generate(&mut rng); +2453 let server_node_id = server_secret_key.public(); +2454 +2455 // Make sure the server is bound before having clients connect to it: +2456 let ep = Endpoint::builder() +2457 .insecure_skip_relay_cert_verify(true) +2458 .secret_key(server_secret_key) +2459 .alpns(vec![TEST_ALPN.to_vec()]) +2460 .relay_mode(RelayMode::Custom(relay_map.clone())) +2461 .bind() +2462 .await?; +2463 // Also make sure the server has a working relay connection +2464 ep.home_relay().initialized().await?; +2465 // The server accepts the connections of the clients sequentially. +2466 let server = tokio::spawn( +2467 async move { +2468 let eps = ep.bound_sockets(); +2469 +2470 info!(me = %ep.node_id().fmt_short(), eps = ?eps, "server listening on"); +2471 for i in 0..n_clients { +2472 let round_start = Instant::now(); +2473 info!("[server] round {i}"); +2474 let incoming = ep.accept().await.e()?; +2475 let conn = incoming.await.e()?; +2476 let node_id = conn.remote_node_id()?; +2477 info!(%i, peer = %node_id.fmt_short(), "accepted connection"); +2478 let (mut send, mut recv) = conn.accept_bi().await.e()?; +2479 let mut buf = vec![0u8; chunk_size]; +2480 for _i in 0..n_chunks_per_client { +2481 recv.read_exact(&mut buf).await.e()?; +2482 send.write_all(&buf).await.e()?; +2483 } +2484 send.finish().e()?; +2485 send.stopped().await.e()?; +2486 recv.read_to_end(0).await.e()?; +2487 info!(%i, peer = %node_id.fmt_short(), "finished"); +2488 info!("[server] round {i} done in {:?}", round_start.elapsed()); +2489 } +2490 Ok::<_, Error>(()) +2491 } +2492 .instrument(error_span!("server")), +2493 ); +2494 +2495 for i in 0..n_clients { +2496 let round_start = Instant::now(); +2497 info!("[client] round {}", i); +2498 let client_secret_key = SecretKey::generate(&mut rng); +2499 async { +2500 info!("client binding"); +2501 let ep = Endpoint::builder() +2502 .alpns(vec![TEST_ALPN.to_vec()]) +2503 .insecure_skip_relay_cert_verify(true) +2504 .relay_mode(RelayMode::Custom(relay_map.clone())) +2505 .secret_key(client_secret_key) +2506 .bind() +2507 .await?; +2508 let eps = ep.bound_sockets(); +2509 +2510 info!(me = %ep.node_id().fmt_short(), eps=?eps, "client bound"); +2511 let node_addr = NodeAddr::new(server_node_id).with_relay_url(relay_url.clone()); +2512 info!(to = ?node_addr, "client connecting"); +2513 let conn = ep.connect(node_addr, TEST_ALPN).await.e()?; +2514 info!("client connected"); +2515 let (mut send, mut recv) = conn.open_bi().await.e()?; +2516 +2517 for i in 0..n_chunks_per_client { +2518 let mut buf = vec![i; chunk_size]; +2519 send.write_all(&buf).await.e()?; +2520 recv.read_exact(&mut buf).await.e()?; +2521 assert_eq!(buf, vec![i; chunk_size]); +2522 } +2523 send.finish().e()?; +2524 send.stopped().await.e()?; +2525 recv.read_to_end(0).await.e()?; +2526 info!("client finished"); +2527 ep.close().await; +2528 info!("client closed"); +2529 Ok::<_, Error>(()) +2530 } +2531 .instrument(error_span!("client", %i)) +2532 .await?; +2533 info!("[client] round {i} done in {:?}", round_start.elapsed()); +2534 } +2535 +2536 server.await.e()??; +2537 +2538 // We appear to have seen this being very slow at times. So ensure we fail if this +2539 // test is too slow. We're only making two connections transferring very little +2540 // data, this really shouldn't take long. +2541 if start.elapsed() > Duration::from_secs(15) { +2542 panic!("Test too slow, something went wrong"); +2543 } +2544 +2545 Ok(()) +2546 } +2547 +2548 #[tokio::test] +2549 #[traced_test] +2550 async fn endpoint_send_relay() -> Result { +2551 let (relay_map, _relay_url, _guard) = run_relay_server().await?; +2552 let client = Endpoint::builder() +2553 .insecure_skip_relay_cert_verify(true) +2554 .relay_mode(RelayMode::Custom(relay_map.clone())) +2555 .bind() +2556 .await?; +2557 let server = Endpoint::builder() +2558 .insecure_skip_relay_cert_verify(true) +2559 .relay_mode(RelayMode::Custom(relay_map)) +2560 .alpns(vec![TEST_ALPN.to_vec()]) +2561 .bind() +2562 .await?; +2563 +2564 let task = tokio::spawn({ +2565 let server = server.clone(); +2566 async move { +2567 let Some(conn) = server.accept().await else { +2568 snafu::whatever!("Expected an incoming connection"); +2569 }; +2570 let conn = conn.await.e()?; +2571 let (mut send, mut recv) = conn.accept_bi().await.e()?; +2572 let data = recv.read_to_end(1000).await.e()?; +2573 send.write_all(&data).await.e()?; +2574 send.finish().e()?; +2575 conn.closed().await; +2576 +2577 Ok::<_, Error>(()) +2578 } +2579 }); +2580 +2581 let addr = server.node_addr().initialized().await?; +2582 let conn = client.connect(addr, TEST_ALPN).await?; +2583 let (mut send, mut recv) = conn.open_bi().await.e()?; +2584 send.write_all(b"Hello, world!").await.e()?; +2585 send.finish().e()?; +2586 let data = recv.read_to_end(1000).await.e()?; +2587 conn.close(0u32.into(), b"bye!"); +2588 +2589 task.await.e()??; +2590 +2591 client.close().await; +2592 server.close().await; +2593 +2594 assert_eq!(&data, b"Hello, world!"); +2595 +2596 Ok(()) +2597 } +2598 +2599 #[tokio::test] +2600 #[traced_test] +2601 async fn endpoint_bidi_send_recv() -> Result { +2602 let ep1 = Endpoint::builder() +2603 .alpns(vec![TEST_ALPN.to_vec()]) +2604 .relay_mode(RelayMode::Disabled); +2605 +2606 let ep1 = ep1.bind().await?; +2607 let ep2 = Endpoint::builder() +2608 .alpns(vec![TEST_ALPN.to_vec()]) +2609 .relay_mode(RelayMode::Disabled); +2610 +2611 let ep2 = ep2.bind().await?; +2612 +2613 let ep1_nodeaddr = ep1.node_addr().initialized().await?; +2614 let ep2_nodeaddr = ep2.node_addr().initialized().await?; +2615 ep1.add_node_addr(ep2_nodeaddr.clone())?; +2616 ep2.add_node_addr(ep1_nodeaddr.clone())?; +2617 let ep1_nodeid = ep1.node_id(); +2618 let ep2_nodeid = ep2.node_id(); +2619 eprintln!("node id 1 {ep1_nodeid}"); +2620 eprintln!("node id 2 {ep2_nodeid}"); +2621 +2622 async fn connect_hello(ep: Endpoint, dst: NodeAddr) -> Result { +2623 let conn = ep.connect(dst, TEST_ALPN).await?; +2624 let (mut send, mut recv) = conn.open_bi().await.e()?; +2625 info!("sending hello"); +2626 send.write_all(b"hello").await.e()?; +2627 send.finish().e()?; +2628 info!("receiving world"); +2629 let m = recv.read_to_end(100).await.e()?; +2630 assert_eq!(m, b"world"); +2631 conn.close(1u8.into(), b"done"); +2632 Ok(()) +2633 } +2634 +2635 async fn accept_world(ep: Endpoint, src: NodeId) -> Result { +2636 let incoming = ep.accept().await.e()?; +2637 let mut iconn = incoming.accept().e()?; +2638 let alpn = iconn.alpn().await?; +2639 let conn = iconn.await.e()?; +2640 let node_id = conn.remote_node_id()?; +2641 assert_eq!(node_id, src); +2642 assert_eq!(alpn, TEST_ALPN); +2643 let (mut send, mut recv) = conn.accept_bi().await.e()?; +2644 info!("receiving hello"); +2645 let m = recv.read_to_end(100).await.e()?; +2646 assert_eq!(m, b"hello"); +2647 info!("sending hello"); +2648 send.write_all(b"world").await.e()?; +2649 send.finish().e()?; +2650 match conn.closed().await { +2651 ConnectionError::ApplicationClosed(closed) => { +2652 assert_eq!(closed.error_code, 1u8.into()); +2653 Ok(()) +2654 } +2655 _ => panic!("wrong close error"), +2656 } +2657 } +2658 +2659 let p1_accept = tokio::spawn(accept_world(ep1.clone(), ep2_nodeid).instrument(info_span!( +2660 "p1_accept", +2661 ep1 = %ep1.node_id().fmt_short(), +2662 dst = %ep2_nodeid.fmt_short(), +2663 ))); +2664 let p2_accept = tokio::spawn(accept_world(ep2.clone(), ep1_nodeid).instrument(info_span!( +2665 "p2_accept", +2666 ep2 = %ep2.node_id().fmt_short(), +2667 dst = %ep1_nodeid.fmt_short(), +2668 ))); +2669 let p1_connect = tokio::spawn(connect_hello(ep1.clone(), ep2_nodeaddr).instrument( +2670 info_span!( +2671 "p1_connect", +2672 ep1 = %ep1.node_id().fmt_short(), +2673 dst = %ep2_nodeid.fmt_short(), +2674 ), +2675 )); +2676 let p2_connect = tokio::spawn(connect_hello(ep2.clone(), ep1_nodeaddr).instrument( +2677 info_span!( +2678 "p2_connect", +2679 ep2 = %ep2.node_id().fmt_short(), +2680 dst = %ep1_nodeid.fmt_short(), +2681 ), +2682 )); +2683 +2684 p1_accept.await.e()??; +2685 p2_accept.await.e()??; +2686 p1_connect.await.e()??; +2687 p2_connect.await.e()??; +2688 +2689 Ok(()) +2690 } +2691 +2692 #[tokio::test] +2693 #[traced_test] +2694 async fn endpoint_conn_type_becomes_direct() -> Result { +2695 const TIMEOUT: Duration = std::time::Duration::from_secs(15); +2696 let (relay_map, _relay_url, _relay_guard) = run_relay_server().await?; +2697 let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(42); +2698 let ep1_secret_key = SecretKey::generate(&mut rng); +2699 let ep2_secret_key = SecretKey::generate(&mut rng); +2700 let ep1 = Endpoint::builder() +2701 .secret_key(ep1_secret_key) +2702 .insecure_skip_relay_cert_verify(true) +2703 .alpns(vec![TEST_ALPN.to_vec()]) +2704 .relay_mode(RelayMode::Custom(relay_map.clone())) +2705 .bind() +2706 .await?; +2707 let ep2 = Endpoint::builder() +2708 .secret_key(ep2_secret_key) +2709 .insecure_skip_relay_cert_verify(true) +2710 .alpns(vec![TEST_ALPN.to_vec()]) +2711 .relay_mode(RelayMode::Custom(relay_map)) +2712 .bind() +2713 .await?; +2714 +2715 async fn wait_for_conn_type_direct(ep: &Endpoint, node_id: NodeId) -> Result { +2716 let mut stream = ep.conn_type(node_id).expect("connection exists").stream(); +2717 let src = ep.node_id().fmt_short(); +2718 let dst = node_id.fmt_short(); +2719 while let Some(conn_type) = stream.next().await { +2720 tracing::info!(me = %src, dst = %dst, conn_type = ?conn_type); +2721 if matches!(conn_type, ConnectionType::Direct(_)) { +2722 return Ok(()); +2723 } +2724 } +2725 snafu::whatever!("conn_type stream ended before `ConnectionType::Direct`"); +2726 } +2727 +2728 async fn accept(ep: &Endpoint) -> Result<Connection> { +2729 let incoming = ep.accept().await.expect("ep closed"); +2730 let conn = incoming.await.e()?; +2731 let node_id = conn.remote_node_id()?; +2732 tracing::info!(node_id=%node_id.fmt_short(), "accepted connection"); +2733 Ok(conn) +2734 } +2735 +2736 let ep1_nodeid = ep1.node_id(); +2737 let ep2_nodeid = ep2.node_id(); +2738 +2739 let ep1_nodeaddr = ep1.node_addr().initialized().await?; +2740 tracing::info!( +2741 "node id 1 {ep1_nodeid}, relay URL {:?}", +2742 ep1_nodeaddr.relay_url() +2743 ); +2744 tracing::info!("node id 2 {ep2_nodeid}"); +2745 +2746 let ep1_side = tokio::time::timeout(TIMEOUT, async move { +2747 let conn = accept(&ep1).await?; +2748 let mut send = conn.open_uni().await.e()?; +2749 wait_for_conn_type_direct(&ep1, ep2_nodeid).await?; +2750 send.write_all(b"Conn is direct").await.e()?; +2751 send.finish().e()?; +2752 conn.closed().await; +2753 Ok::<(), Error>(()) +2754 }); +2755 +2756 let ep2_side = tokio::time::timeout(TIMEOUT, async move { +2757 let conn = ep2.connect(ep1_nodeaddr, TEST_ALPN).await?; +2758 let mut recv = conn.accept_uni().await.e()?; +2759 wait_for_conn_type_direct(&ep2, ep1_nodeid).await?; +2760 let read = recv.read_to_end(100).await.e()?; +2761 assert_eq!(read, b"Conn is direct".to_vec()); +2762 conn.close(0u32.into(), b"done"); +2763 conn.closed().await; +2764 Ok::<(), Error>(()) +2765 }); +2766 +2767 let res_ep1 = AbortOnDropHandle::new(tokio::spawn(ep1_side)); +2768 let res_ep2 = AbortOnDropHandle::new(tokio::spawn(ep2_side)); +2769 +2770 let (r1, r2) = tokio::try_join!(res_ep1, res_ep2).e()?; +2771 r1.e()??; +2772 r2.e()??; +2773 +2774 Ok(()) +2775 } +2776 +2777 #[tokio::test] +2778 #[traced_test] +2779 async fn test_direct_addresses_no_qad_relay() -> Result { +2780 let (relay_map, _, _guard) = run_relay_server_with(false).await.unwrap(); +2781 +2782 let ep = Endpoint::builder() +2783 .alpns(vec![TEST_ALPN.to_vec()]) +2784 .relay_mode(RelayMode::Custom(relay_map)) +2785 .insecure_skip_relay_cert_verify(true) +2786 .bind() +2787 .await?; +2788 +2789 tokio::time::timeout(Duration::from_secs(10), ep.direct_addresses().initialized()) +2790 .await +2791 .e()??; +2792 Ok(()) +2793 } +2794 +2795 async fn spawn_0rtt_server(secret_key: SecretKey, log_span: tracing::Span) -> Result<Endpoint> { +2796 let server = Endpoint::builder() +2797 .secret_key(secret_key) +2798 .alpns(vec![TEST_ALPN.to_vec()]) +2799 .relay_mode(RelayMode::Disabled) +2800 .bind() +2801 .await?; +2802 +2803 // Gets aborted via the endpoint closing causing an `Err` +2804 // a simple echo server +2805 tokio::spawn({ +2806 let server = server.clone(); +2807 async move { +2808 while let Some(incoming) = server.accept().await { +2809 let connecting = incoming.accept().e()?; +2810 let conn = match connecting.into_0rtt() { +2811 Ok((conn, _)) => { +2812 info!("0rtt accepted"); +2813 conn +2814 } +2815 Err(connecting) => { +2816 info!("0rtt denied"); +2817 connecting.await.e()? +2818 } +2819 }; +2820 let (mut send, mut recv) = conn.accept_bi().await.e()?; +2821 let data = recv.read_to_end(10_000_000).await.e()?; +2822 send.write_all(&data).await.e()?; +2823 send.finish().e()?; +2824 +2825 // Stay alive until the other side closes the connection. +2826 conn.closed().await; +2827 } +2828 Ok::<_, Error>(()) +2829 } +2830 .instrument(log_span) +2831 }); +2832 +2833 Ok(server) +2834 } +2835 +2836 async fn connect_client_0rtt_expect_err(client: &Endpoint, server_addr: NodeAddr) -> Result { +2837 let conn = client +2838 .connect_with_opts(server_addr, TEST_ALPN, ConnectOptions::new()) +2839 .await? +2840 .into_0rtt() +2841 .expect_err("expected 0rtt to fail") +2842 .await +2843 .e()?; +2844 +2845 let (mut send, mut recv) = conn.open_bi().await.e()?; +2846 send.write_all(b"hello").await.e()?; +2847 send.finish().e()?; +2848 let received = recv.read_to_end(1_000).await.e()?; +2849 assert_eq!(&received, b"hello"); +2850 conn.close(0u32.into(), b"thx"); +2851 Ok(()) +2852 } +2853 +2854 async fn connect_client_0rtt_expect_ok( +2855 client: &Endpoint, +2856 server_addr: NodeAddr, +2857 expect_server_accepts: bool, +2858 ) -> Result { +2859 let (conn, accepted_0rtt) = client +2860 .connect_with_opts(server_addr, TEST_ALPN, ConnectOptions::new()) +2861 .await? +2862 .into_0rtt() +2863 .ok() +2864 .e()?; +2865 +2866 // This is how we send data in 0-RTT: +2867 let (mut send, recv) = conn.open_bi().await.e()?; +2868 send.write_all(b"hello").await.e()?; +2869 send.finish().e()?; +2870 // When this resolves, we've gotten a response from the server about whether the 0-RTT data above was accepted: +2871 let accepted = accepted_0rtt.await; +2872 assert_eq!(accepted, expect_server_accepts); +2873 let mut recv = if accepted { +2874 recv +2875 } else { +2876 // in this case we need to re-send data by re-creating the connection. +2877 let (mut send, recv) = conn.open_bi().await.e()?; +2878 send.write_all(b"hello").await.e()?; +2879 send.finish().e()?; +2880 recv +2881 }; +2882 let received = recv.read_to_end(1_000).await.e()?; +2883 assert_eq!(&received, b"hello"); +2884 conn.close(0u32.into(), b"thx"); +2885 Ok(()) +2886 } +2887 +2888 #[tokio::test] +2889 #[traced_test] +2890 async fn test_0rtt() -> Result { +2891 let client = Endpoint::builder() +2892 .relay_mode(RelayMode::Disabled) +2893 .bind() +2894 .await?; +2895 let server = spawn_0rtt_server( +2896 SecretKey::generate(rand::thread_rng()), +2897 info_span!("server"), +2898 ) +2899 .await?; +2900 +2901 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; +2902 // The second 0rtt attempt should work +2903 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) +2904 .await?; +2905 +2906 client.close().await; +2907 server.close().await; +2908 +2909 Ok(()) +2910 } +2911 +2912 // We have this test, as this would've failed at some point. +2913 // This effectively tests that we correctly categorize the TLS session tickets we +2914 // receive into the respective "bucket" for the recipient. +2915 #[tokio::test] +2916 #[traced_test] +2917 async fn test_0rtt_non_consecutive() -> Result { +2918 let client = Endpoint::builder() +2919 .relay_mode(RelayMode::Disabled) +2920 .bind() +2921 .await?; +2922 let server = spawn_0rtt_server( +2923 SecretKey::generate(rand::thread_rng()), +2924 info_span!("server"), +2925 ) +2926 .await?; +2927 +2928 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; +2929 +2930 // connecting with another endpoint should not interfere with our +2931 // TLS session ticket cache for the first endpoint: +2932 let another = spawn_0rtt_server( +2933 SecretKey::generate(rand::thread_rng()), +2934 info_span!("another"), +2935 ) +2936 .await?; +2937 connect_client_0rtt_expect_err(&client, another.node_addr().initialized().await?).await?; +2938 another.close().await; +2939 +2940 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) +2941 .await?; +2942 +2943 client.close().await; +2944 server.close().await; +2945 +2946 Ok(()) +2947 } +2948 +2949 // Test whether 0-RTT is possible after a restart: +2950 #[tokio::test] +2951 #[traced_test] +2952 async fn test_0rtt_after_server_restart() -> Result { +2953 let client = Endpoint::builder() +2954 .relay_mode(RelayMode::Disabled) +2955 .bind() +2956 .await?; +2957 let server_key = SecretKey::generate(rand::thread_rng()); +2958 let server = spawn_0rtt_server(server_key.clone(), info_span!("server-initial")).await?; +2959 +2960 connect_client_0rtt_expect_err(&client, server.node_addr().initialized().await?).await?; +2961 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, true) +2962 .await?; +2963 +2964 server.close().await; +2965 +2966 let server = spawn_0rtt_server(server_key, info_span!("server-restart")).await?; +2967 +2968 // we expect the client to *believe* it can 0-RTT connect to the server (hence expect_ok), +2969 // but the server will reject the early data because it discarded necessary state +2970 // to decrypt it when restarting. +2971 connect_client_0rtt_expect_ok(&client, server.node_addr().initialized().await?, false) +2972 .await?; +2973 +2974 client.close().await; +2975 +2976 Ok(()) +2977 } +2978 +2979 #[cfg_attr(target_os = "windows", ignore = "flaky")] +2980 #[tokio::test] +2981 #[traced_test] +2982 async fn graceful_close() -> Result { +2983 let client = Endpoint::builder().bind().await?; +2984 let server = Endpoint::builder() +2985 .alpns(vec![TEST_ALPN.to_vec()]) +2986 .bind() +2987 .await?; +2988 let server_addr = server.node_addr().initialized().await?; +2989 let server_task = tokio::spawn(async move { +2990 let incoming = server.accept().await.e()?; +2991 let conn = incoming.await.e()?; +2992 let (mut send, mut recv) = conn.accept_bi().await.e()?; +2993 let msg = recv.read_to_end(1_000).await.e()?; +2994 send.write_all(&msg).await.e()?; +2995 send.finish().e()?; +2996 let close_reason = conn.closed().await; +2997 Ok::<_, Error>(close_reason) +2998 }); +2999 +3000 let conn = client.connect(server_addr, TEST_ALPN).await?; +3001 let (mut send, mut recv) = conn.open_bi().await.e()?; +3002 send.write_all(b"Hello, world!").await.e()?; +3003 send.finish().e()?; +3004 recv.read_to_end(1_000).await.e()?; +3005 conn.close(42u32.into(), b"thanks, bye!"); +3006 client.close().await; +3007 +3008 let close_err = server_task.await.e()??; +3009 let ConnectionError::ApplicationClosed(app_close) = close_err else { +3010 panic!("Unexpected close reason: {close_err:?}"); +3011 }; +3012 +3013 assert_eq!(app_close.error_code, 42u32.into()); +3014 assert_eq!(app_close.reason.as_ref(), b"thanks, bye!"); +3015 +3016 Ok(()) +3017 } +3018 +3019 #[cfg(feature = "metrics")] +3020 #[tokio::test] +3021 #[traced_test] +3022 async fn metrics_smoke() -> Result { +3023 use iroh_metrics::{MetricsSource, Registry}; +3024 +3025 let secret_key = SecretKey::from_bytes(&[0u8; 32]); +3026 let client = Endpoint::builder() +3027 .secret_key(secret_key) +3028 .relay_mode(RelayMode::Disabled) +3029 .bind() +3030 .await?; +3031 let secret_key = SecretKey::from_bytes(&[1u8; 32]); +3032 let server = Endpoint::builder() +3033 .secret_key(secret_key) +3034 .relay_mode(RelayMode::Disabled) +3035 .alpns(vec![TEST_ALPN.to_vec()]) +3036 .bind() +3037 .await?; +3038 let server_addr = server.node_addr().initialized().await?; +3039 let server_task = tokio::task::spawn(async move { +3040 let conn = server.accept().await.e()?.accept().e()?.await.e()?; +3041 let mut uni = conn.accept_uni().await.e()?; +3042 uni.read_to_end(10).await.e()?; +3043 drop(conn); +3044 Ok::<_, Error>(server) +3045 }); +3046 let conn = client.connect(server_addr, TEST_ALPN).await?; +3047 let mut uni = conn.open_uni().await.e()?; +3048 uni.write_all(b"helloworld").await.e()?; +3049 uni.finish().e()?; +3050 conn.closed().await; +3051 drop(conn); +3052 let server = server_task.await.e()??; +3053 +3054 let m = client.metrics(); +3055 assert_eq!(m.magicsock.num_direct_conns_added.get(), 1); +3056 assert_eq!(m.magicsock.connection_became_direct.get(), 1); +3057 assert_eq!(m.magicsock.connection_handshake_success.get(), 1); +3058 assert_eq!(m.magicsock.nodes_contacted_directly.get(), 1); +3059 assert!(m.magicsock.recv_datagrams.get() > 0); +3060 +3061 let m = server.metrics(); +3062 assert_eq!(m.magicsock.num_direct_conns_added.get(), 1); +3063 assert_eq!(m.magicsock.connection_became_direct.get(), 1); +3064 assert_eq!(m.magicsock.nodes_contacted_directly.get(), 1); +3065 assert_eq!(m.magicsock.connection_handshake_success.get(), 1); +3066 assert!(m.magicsock.recv_datagrams.get() > 0); +3067 +3068 // test openmetrics encoding with labeled subregistries per endpoint +3069 fn register_endpoint(registry: &mut Registry, endpoint: &Endpoint) { +3070 let id = endpoint.node_id().fmt_short(); +3071 let sub_registry = registry.sub_registry_with_label("id", id); +3072 sub_registry.register_all(endpoint.metrics()); +3073 } +3074 let mut registry = Registry::default(); +3075 register_endpoint(&mut registry, &client); +3076 register_endpoint(&mut registry, &server); +3077 let s = registry.encode_openmetrics_to_string()?; +3078 assert!(s.contains(r#"magicsock_nodes_contacted_directly_total{id="3b6a27bcce"} 1"#)); +3079 assert!(s.contains(r#"magicsock_nodes_contacted_directly_total{id="8a88e3dd74"} 1"#)); +3080 Ok(()) +3081 } +3082 +3083 /// Configures the accept side to take `accept_alpns` ALPNs, then connects to it with `primary_connect_alpn` +3084 /// with `secondary_connect_alpns` set, and finally returns the negotiated ALPN. +3085 async fn alpn_connection_test( +3086 accept_alpns: Vec<Vec<u8>>, +3087 primary_connect_alpn: &[u8], +3088 secondary_connect_alpns: Vec<Vec<u8>>, +3089 ) -> Result<Option<Vec<u8>>> { +3090 let client = Endpoint::builder() +3091 .relay_mode(RelayMode::Disabled) +3092 .bind() +3093 .await?; +3094 let server = Endpoint::builder() +3095 .relay_mode(RelayMode::Disabled) +3096 .alpns(accept_alpns) +3097 .bind() +3098 .await?; +3099 let server_addr = server.node_addr().initialized().await?; +3100 let server_task = tokio::spawn({ +3101 let server = server.clone(); +3102 async move { +3103 let incoming = server.accept().await.e()?; +3104 let conn = incoming.await.e()?; +3105 conn.close(0u32.into(), b"bye!"); +3106 Ok::<_, n0_snafu::Error>(conn.alpn()) +3107 } +3108 }); +3109 +3110 let conn = client +3111 .connect_with_opts( +3112 server_addr, +3113 primary_connect_alpn, +3114 ConnectOptions::new().with_additional_alpns(secondary_connect_alpns), +3115 ) +3116 .await?; +3117 let conn = conn.await.e()?; +3118 let client_alpn = conn.alpn(); +3119 conn.closed().await; +3120 client.close().await; +3121 server.close().await; +3122 +3123 let server_alpn = server_task.await.e()??; +3124 +3125 assert_eq!(client_alpn, server_alpn); +3126 +3127 Ok(server_alpn) +3128 } +3129 +3130 #[tokio::test] +3131 #[traced_test] +3132 async fn connect_multiple_alpn_negotiated() -> Result { +3133 const ALPN_ONE: &[u8] = b"alpn/1"; +3134 const ALPN_TWO: &[u8] = b"alpn/2"; +3135 +3136 assert_eq!( +3137 alpn_connection_test( +3138 // Prefer version 2 over version 1 on the accept side +3139 vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], +3140 ALPN_TWO, +3141 vec![ALPN_ONE.to_vec()], +3142 ) +3143 .await?, +3144 Some(ALPN_TWO.to_vec()), +3145 "accept side prefers version 2 over 1" +3146 ); +3147 +3148 assert_eq!( +3149 alpn_connection_test( +3150 // Only support the old version +3151 vec![ALPN_ONE.to_vec()], +3152 ALPN_TWO, +3153 vec![ALPN_ONE.to_vec()], +3154 ) +3155 .await?, +3156 Some(ALPN_ONE.to_vec()), +3157 "accept side only supports the old version" +3158 ); +3159 +3160 assert_eq!( +3161 alpn_connection_test( +3162 vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], +3163 ALPN_ONE, +3164 vec![ALPN_TWO.to_vec()], +3165 ) +3166 .await?, +3167 Some(ALPN_TWO.to_vec()), +3168 "connect side ALPN order doesn't matter" +3169 ); +3170 +3171 assert_eq!( +3172 alpn_connection_test(vec![ALPN_TWO.to_vec(), ALPN_ONE.to_vec()], ALPN_ONE, vec![],) +3173 .await?, +3174 Some(ALPN_ONE.to_vec()), +3175 "connect side only supports the old version" +3176 ); +3177 +3178 Ok(()) +3179 } +3180 +3181 #[tokio::test] +3182 #[traced_test] +3183 async fn watch_net_report() -> Result { +3184 let endpoint = Endpoint::builder() +3185 .relay_mode(RelayMode::Staging) +3186 .bind() +3187 .await?; +3188 +3189 // can get a first report +3190 endpoint.net_report().updated().await?; +3191 +3192 Ok(()) +3193 } +3194}

    \ No newline at end of file diff --git a/pr/3402/docs/trait.impl/core/convert/trait.From.js b/pr/3402/docs/trait.impl/core/convert/trait.From.js index f0569cfc00..4e23081354 100644 --- a/pr/3402/docs/trait.impl/core/convert/trait.From.js +++ b/pr/3402/docs/trait.impl/core/convert/trait.From.js @@ -1,9 +1,9 @@ (function() { - var implementors = Object.fromEntries([["iroh",[["impl From<IntoDiscoveryError> for BindError"],["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>>,
    "],["impl<T: ProtocolHandler> From<T> for Box<dyn DynProtocolHandler>"]]],["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<Error> for ParseError"],["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<DnsError> for DialError"],["impl From<DecodingError> for ParseError"],["impl From<FrameType> for u32"],["impl From<FrameType> for VarInt"],["impl From<FrameTypeError> for Error"],["impl From<FrameTypeError> for Error"],["impl From<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for DialError"],["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<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for Error"],["impl From<Error> for Error"],["impl From<JoinError> for SupervisorError"],["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"],["impl<T: AsRef<[u8]>> From<T> for Datagrams"]]]]); + var implementors = Object.fromEntries([["iroh",[["impl From<IntoDiscoveryError> for BindError"],["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>>,
    "],["impl<T: ProtocolHandler> From<T> for Box<dyn DynProtocolHandler>"]]],["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<Error> for ParseError"],["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<DnsError> for DialError"],["impl From<DecodingError> for ParseError"],["impl From<FrameType> for u32"],["impl From<FrameType> for VarInt"],["impl From<FrameTypeError> for Error"],["impl From<FrameTypeError> for Error"],["impl From<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for DialError"],["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<Error> for ConnectError"],["impl From<Error> for RecvError"],["impl From<Error> for SendError"],["impl From<Error> for Error"],["impl From<Error> for Error"],["impl From<JoinError> for SupervisorError"],["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"],["impl<T: AsRef<[u8]>> From<T> for Datagrams"]]]]); if (window.register_implementors) { window.register_implementors(implementors); } else { window.pending_implementors = implementors; } })() -//{"start":57,"fragment_lengths":[7257,4938,10863]} \ No newline at end of file +//{"start":57,"fragment_lengths":[7257,4938,11473]} \ No newline at end of file diff --git a/pr/3402/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js b/pr/3402/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js index d104c409e3..8cd585bc9e 100644 --- a/pr/3402/docs/trait.impl/core/iter/traits/collect/trait.FromIterator.js +++ b/pr/3402/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