#[non_exhaustive]pub struct EndpointConfig {
pub secret_key: Option<SecretKey>,
pub mdns: Mdns,
}Expand description
An endpoint with MoqPreset, a key and mDNS.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.secret_key: Option<SecretKey>The endpoint’s identity. None generates an ephemeral one.
mdns: MdnsHow the endpoint uses mDNS.
Implementations§
Source§impl EndpointConfig
impl EndpointConfig
Sourcepub fn with_secret_key(self, secret_key: SecretKey) -> Self
pub fn with_secret_key(self, secret_key: SecretKey) -> Self
Returns this config with secret_key as the endpoint’s identity.
Sourcepub fn with_mdns(self, mdns: Mdns) -> Self
pub fn with_mdns(self, mdns: Mdns) -> Self
Returns this config with mdns as how the endpoint uses mDNS.
Sourcepub fn from_env() -> Result<Self, EndpointError>
pub fn from_env() -> Result<Self, EndpointError>
Returns the default config with the secret key in IROH_SECRET, if set.
Set IROH_SECRET to keep one endpoint id, and so the same tickets,
across restarts.
§Errors
Fails with EndpointError::SecretKey if IROH_SECRET is set to
something that is not a secret key.
Sourcepub fn apply(self, builder: Builder) -> Builder
pub fn apply(self, builder: Builder) -> Builder
Applies this config to builder and returns it.
This sets MoqPreset, the key and mDNS, for a caller that builds
its own endpoint. The preset sets the iroh relay mode, the address lookups
and the QUIC transport config with BBR3, so make your own settings
after this call, not before. For another congestion controller, set
transport_config(Congestion::Cubic.transport_config()) afterwards
(see Congestion).
The mDNS lookup starts when the endpoint binds. If it cannot start, as in a sandbox or on a phone without a multicast lock, the endpoint logs a warning and goes without it.
use iroh::{RelayMode, endpoint::Builder};
use iroh_live_node::EndpointConfig;
let endpoint = EndpointConfig::from_env()?
.apply(Builder::empty())
.relay_mode(RelayMode::Disabled)
.bind()
.await?;Sourcepub async fn bind(self) -> Result<Endpoint, EndpointError>
pub async fn bind(self) -> Result<Endpoint, EndpointError>
Binds an endpoint with MoqPreset and this config.
The endpoint accepts no ALPN until a router mounts handlers on it. The caller owns it: close it, or shut down the router built on it, which closes it.
§Errors
Fails with EndpointError::Bind if the endpoint’s sockets cannot be
bound.