pub struct NodeAddr {
pub node_id: NodeId,
pub info: AddrInfo,
}Expand description
Network-level addressing information for an iroh-net node.
This combines a node’s identifier with network-level addressing information of how to contact the node.
To establish a network connection to a node both the NodeId and one or more network
paths are needed. The network paths can come from various sources:
-
A discovery service which can provide routing information for a given
NodeId. -
A
RelayUrlof the node’s home relay, this allows establishing the connection via the Relay server and is very reliable. -
One or more direct addresses on which the node might be reachable. Depending on the network location of both nodes it might not be possible to establish a direct connection without the help of a Relay server.
This structure will always contain the required NodeId and will contain an optional
number of network-level addressing information. It is a generic addressing type used
whenever a connection to other nodes needs to be established.
Fields§
§node_id: NodeIdThe node’s identifier.
info: AddrInfoAddressing information to connect to Self::node_id.
Implementations§
source§impl NodeAddr
impl NodeAddr
sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a relay url to the node’s AddrInfo.
sourcepub fn with_direct_addresses(
self,
addresses: impl IntoIterator<Item = SocketAddr>
) -> Self
pub fn with_direct_addresses( self, addresses: impl IntoIterator<Item = SocketAddr> ) -> Self
Adds the given direct addresses to the peer’s AddrInfo.
sourcepub fn from_parts(
node_id: PublicKey,
relay_url: Option<RelayUrl>,
direct_addresses: Vec<SocketAddr>
) -> Self
pub fn from_parts( node_id: PublicKey, relay_url: Option<RelayUrl>, direct_addresses: Vec<SocketAddr> ) -> Self
Creates a new NodeAddr from its parts.
sourcepub fn apply_options(&mut self, opts: AddrInfoOptions)
pub fn apply_options(&mut self, opts: AddrInfoOptions)
sourcepub fn direct_addresses(&self) -> impl Iterator<Item = &SocketAddr>
pub fn direct_addresses(&self) -> impl Iterator<Item = &SocketAddr>
Returns the direct addresses of this peer.
Trait Implementations§
source§impl<'de> Deserialize<'de> for NodeAddr
impl<'de> Deserialize<'de> for NodeAddr
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for NodeAddr
impl Ord for NodeAddr
source§impl PartialEq for NodeAddr
impl PartialEq for NodeAddr
source§impl PartialOrd for NodeAddr
impl PartialOrd for NodeAddr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more