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:
-
An Address Lookup service which can provide routing information for a given
EndpointId. -
A
RelayUrlof 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: EndpointIdThe 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. an address lookup 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 an EndpointId is present.
Sourcepub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
pub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
Returns an iterator over the IP addresses of this endpoint address.
Sourcepub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
pub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
Returns an iterator over the relay URLs of this endpoint address.
In practice this is expected to be zero or one home relay for all known cases currently.