pub struct NodeAddr {
    pub node_id: NodeId,
    pub relay_url: Option<RelayUrl>,
    pub direct_addresses: BTreeSet<SocketAddr>,
}key only.Expand description
Network-level addressing information for an iroh 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.
relay_url: Option<RelayUrl>The node’s home relay url.
direct_addresses: BTreeSet<SocketAddr>Socket addresses where the peer might be reached directly.
Implementations§
Source§impl NodeAddr
 
impl NodeAddr
Sourcepub fn new(node_id: PublicKey) -> Self
 
pub fn new(node_id: PublicKey) -> Self
Creates a new NodeAddr with no relay_url and no direct_addresses.
Sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
 
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a relay url.
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.
Sourcepub fn from_parts(
    node_id: PublicKey,
    relay_url: Option<RelayUrl>,
    direct_addresses: impl IntoIterator<Item = SocketAddr>,
) -> Self
 
pub fn from_parts( node_id: PublicKey, relay_url: Option<RelayUrl>, direct_addresses: impl IntoIterator<Item = SocketAddr>, ) -> Self
Creates a new NodeAddr from its parts.
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 From<NodeAddr> for NodeTicket
Available on crate feature ticket only. 
impl From<NodeAddr> for NodeTicket
ticket only.Source§impl From<NodeTicket> for NodeAddr
Available on crate feature ticket only. 
impl From<NodeTicket> for NodeAddr
ticket only.Source§fn from(ticket: NodeTicket) -> Self
 
fn from(ticket: NodeTicket) -> Self
Returns the addressing info from given ticket.