pub struct Builder { /* private fields */ }Expand description
Builder for Endpoint.
By default the endpoint will generate a new random SecretKey, which will result in a
new EndpointId.
To create the Endpoint call Builder::bind.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn empty(relay_mode: RelayMode) -> Self
pub fn empty(relay_mode: RelayMode) -> Self
Creates an empty builder with no discovery services.
Sourcepub fn bind_addr_v4(self, bind_addr: SocketAddrV4) -> Self
Available on non-wasm_browser only.
pub fn bind_addr_v4(self, bind_addr: SocketAddrV4) -> Self
wasm_browser only.Adds an IP transport, binding to the provided IPv4 address.
If you want to remove the default transports, make sure to call clear_ip first.
Setting the port to 0 will use a random port.
If the port specified is already in use, it will fallback to choosing a random port.
Sourcepub fn bind_addr_v6(self, bind_addr: SocketAddrV6) -> Self
Available on non-wasm_browser only.
pub fn bind_addr_v6(self, bind_addr: SocketAddrV6) -> Self
wasm_browser only.Adds an IP transport, binding to the provided IPv6 address.
If you want to remove the default transports, make sure to call clear_ip first.
Setting the port to 0 will use a random port.
If the port specified is already in use, it will fallback to choosing a random port.
Sourcepub fn clear_ip_transports(self) -> Self
Available on non-wasm_browser only.
pub fn clear_ip_transports(self) -> Self
wasm_browser only.Removes all IP based transports
Sourcepub fn clear_relay_transports(self) -> Self
pub fn clear_relay_transports(self) -> Self
Removes all relay based transports
Sourcepub fn secret_key(self, secret_key: SecretKey) -> Self
pub fn secret_key(self, secret_key: SecretKey) -> Self
Sets a secret key to authenticate with other peers.
This secret key’s public key will be the PublicKey of this endpoint and thus
also its EndpointId
If not set, a new secret key will be generated.
Sourcepub fn relay_mode(self, relay_mode: RelayMode) -> Self
pub fn relay_mode(self, relay_mode: RelayMode) -> Self
Sets the relay servers to assist in establishing connectivity.
Relay servers are used to establish initial connection with another iroh endpoint. They also perform various functions related to hole punching, see the crate docs for more details.
By default the number 0 relay servers are used, see RelayMode::Default.
When using RelayMode::Custom, the provided relay_map must contain at least one
configured relay endpoint. If an invalid RelayMap is provided bind
will result in an error.
Sourcepub fn clear_discovery(self) -> Self
pub fn clear_discovery(self) -> Self
Removes all discovery services from the builder.
If no discovery service is set, connecting to an endpoint without providing its direct addresses or relay URLs will fail.
See the documentation of the crate::discovery::Discovery trait for details.
Sourcepub fn discovery(self, discovery: impl IntoDiscovery) -> Self
pub fn discovery(self, discovery: impl IntoDiscovery) -> Self
Adds a discovery mechanism for this endpoint.
The function discovery
will be called on endpoint creation with the configured secret key of
the endpoint. Discovery services that need to publish information need
to use this secret key to sign the information.
If you add multiple discovery services, they will be combined using a
crate::discovery::ConcurrentDiscovery.
If no discovery service is set, connecting to an endpoint without providing its direct addresses or relay URLs will fail.
To clear all discovery services, use Builder::clear_discovery.
See the documentation of the crate::discovery::Discovery trait for details.
Sourcepub fn user_data_for_discovery(self, user_data: UserData) -> Self
pub fn user_data_for_discovery(self, user_data: UserData) -> Self
Sets the initial user-defined data to be published in discovery services for this node.
When using discovery services, this string of UserData will be published together
with the endpoint’s addresses and relay URL. When other endpoints discover this endpoint,
they retrieve the UserData in addition to the addressing info.
Iroh itself does not interpret the user-defined data in any way, it is purely left for applications to parse and use.
Sourcepub fn transport_config(self, transport_config: TransportConfig) -> Self
pub fn transport_config(self, transport_config: TransportConfig) -> Self
Sets a custom quinn::TransportConfig for this endpoint.
The transport config contains parameters governing the QUIC state machine.
If unset, the default config is used. Default values should be suitable for most
internet applications. Applications protocols which forbid remotely-initiated
streams should set max_concurrent_bidi_streams and max_concurrent_uni_streams to
zero.
Please be aware that changing some settings may have adverse effects on establishing and maintaining direct connections.
Sourcepub fn dns_resolver(self, dns_resolver: DnsResolver) -> Self
Available on non-wasm_browser only.
pub fn dns_resolver(self, dns_resolver: DnsResolver) -> Self
wasm_browser only.Optionally sets a custom DNS resolver to use for this endpoint.
The DNS resolver is used to resolve relay hostnames, and endpoint addresses if
crate::discovery::dns::DnsDiscovery is configured.
By default, a new DNS resolver is created which is configured to use the
host system’s DNS configuration. You can pass a custom instance of DnsResolver
here to use a differently configured DNS resolver for this endpoint, or to share
a DnsResolver between multiple endpoints.
Sourcepub fn proxy_url(self, url: Url) -> Self
pub fn proxy_url(self, url: Url) -> Self
Sets an explicit proxy url to proxy all HTTP(S) traffic through.
Sourcepub fn proxy_from_env(self) -> Self
pub fn proxy_from_env(self) -> Self
Sets the proxy url from the environment, in this order:
HTTP_PROXYhttp_proxyHTTPS_PROXYhttps_proxy
Sourcepub fn keylog(self, keylog: bool) -> Self
pub fn keylog(self, keylog: bool) -> Self
Enables saving the TLS pre-master key for connections.
This key should normally remain secret but can be useful to debug networking issues by decrypting captured traffic.
If keylog is true then setting the SSLKEYLOGFILE environment variable to a
filename will result in this file being used to log the TLS pre-master keys.
Sourcepub fn insecure_skip_relay_cert_verify(self, skip_verify: bool) -> Self
Available on crate features test-utils only.
pub fn insecure_skip_relay_cert_verify(self, skip_verify: bool) -> Self
test-utils only.Skip verification of SSL certificates from relay servers
May only be used in tests.
Sourcepub fn max_tls_tickets(self, n: usize) -> Self
pub fn max_tls_tickets(self, n: usize) -> Self
Set the maximum number of TLS tickets to cache.
Set this to a larger value if you want to do 0rtt connections to a large number of clients.
The default is 256, taking about 150 KiB in memory.