pub struct EndpointAddr {
pub id: EndpointId,
pub addrs: BTreeSet<TransportAddr>,
}
key
only.Expand description
Network-level addressing information for an iroh endpoint.
This combines an endpoint’s identifier with network-level addressing information of how to contact the endpoint.
To establish a network connection to an endpoint both the EndpointId
and one or more network
paths are needed. The network paths can come from various sources, current sources can come from
-
A discovery service which can provide routing information for a given
EndpointId
. -
A
RelayUrl
of the endpoint’s home relay, this allows establishing the connection via the Relay server and is very reliable. -
One or more IP based addresses on which the endpoint might be reachable. Depending on the network location of both endpoints it might not be possible to establish a direct connection without the help of a Relay server.
This structure will always contain the required EndpointId
and will contain an optional
number of other addressing information. It is a generic addressing type used whenever a connection
to other endpoints needs to be established.
Fields§
§id: EndpointId
The endpoint’s identifier.
addrs: BTreeSet<TransportAddr>
The endpoint’s addresses
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
Sourcepub fn new(id: PublicKey) -> Self
pub fn new(id: PublicKey) -> Self
Creates a new EndpointAddr
with no network level addresses.
This still is usable with e.g. a discovery service to establish a connection, depending on the situation.
Sourcepub fn from_parts(
id: PublicKey,
addrs: impl IntoIterator<Item = TransportAddr>,
) -> Self
pub fn from_parts( id: PublicKey, addrs: impl IntoIterator<Item = TransportAddr>, ) -> Self
Creates a new EndpointAddr
from its parts.
Sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a RelayUrl
address.
Sourcepub fn with_ip_addr(self, addr: SocketAddr) -> Self
pub fn with_ip_addr(self, addr: SocketAddr) -> Self
Adds an IP based address.
Sourcepub fn with_addrs(self, addrs: impl IntoIterator<Item = TransportAddr>) -> Self
pub fn with_addrs(self, addrs: impl IntoIterator<Item = TransportAddr>) -> Self
Adds a list of addresses.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true, if only a EndpointId
is present.
Sourcepub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
pub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
Returns a list of IP addresses of this peer.
Sourcepub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
pub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
Returns a list of relay urls of this peer.
In practice this is expected to be zero or one home relay for all known cases currently.
Trait Implementations§
Source§impl Clone for EndpointAddr
impl Clone for EndpointAddr
Source§fn clone(&self) -> EndpointAddr
fn clone(&self) -> EndpointAddr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more