Endpoint

An iroh endpoint.

Bind one with `Endpoint::bind`. Provide protocol handlers via `EndpointOptions::protocols` to dispatch incoming connections.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun acceptNext(): Incoming?

Pull the next incoming connection attempt from the accept queue.

Link copied to clipboard
open suspend override fun addExternalAddr(addr: String)

Add an external (manually-known) socket address that this endpoint is reachable on. Useful when running behind a static NAT / load balancer.

Link copied to clipboard
open override fun addr(): EndpointAddr

The `EndpointAddr` for this endpoint (id + currently known addresses).

Link copied to clipboard
open override fun boundSockets(): List<String>

The local socket addresses this endpoint is bound to.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun connect(addr: EndpointAddr, alpn: ByteArray): Connection

Connect to a remote endpoint via the given ALPN.

Link copied to clipboard
open suspend override fun connectPending(addr: EndpointAddr, alpn: ByteArray): Connecting

Begin a connection attempt to addr for alpn, returning the in-progress `Connecting` state.

Link copied to clipboard
open override fun destroy()
Link copied to clipboard
open override fun id(): EndpointId

The `EndpointId` of this endpoint.

Link copied to clipboard
open suspend override fun insertRelay(config: RelayConfig)

Insert (or replace) a relay configuration at runtime.

Link copied to clipboard
open override fun isClosed(): Boolean

Returns true if the endpoint has been closed.

Link copied to clipboard
open suspend override fun online()

Resolves once the endpoint has a usable home relay.

Link copied to clipboard
open suspend override fun remoteAddr(id: EndpointId): EndpointAddr?

Look up cached information about a remote endpoint, if any.

Link copied to clipboard
open suspend override fun removeExternalAddr(addr: String): Boolean

Remove a previously-added external address. Returns true if an entry was removed.

Link copied to clipboard
open suspend override fun removeRelay(url: String): Boolean

Remove a relay configuration at runtime. Returns true if a relay was removed.

Link copied to clipboard
open override fun secretKey(): SecretKey

The `SecretKey` backing this endpoint's identity.

Link copied to clipboard
open override fun setAlpns(alpns: List<ByteArray>)

Replace the set of ALPNs advertised by this endpoint.

Link copied to clipboard
open suspend override fun shutdown()

Shut down the endpoint (and, if present, the protocol router).

Link copied to clipboard
open override fun stats(): Map<String, CounterStats>

Get current statistics for this endpoint.

Link copied to clipboard
open override fun watchAddr(callback: AddrChangeCallback): WatchHandle

Register a callback that fires whenever the endpoint's `EndpointAddr` changes (relay home rotates, IP discovered, etc.). The returned `WatchHandle` cancels the watcher when dropped or when its stop() method is called.

Link copied to clipboard
open override fun watchHomeRelay(callback: HomeRelayCallback): WatchHandle

Register a callback that fires whenever the list of relays this endpoint is currently connected to changes.

Link copied to clipboard

Register a callback that fires every time the underlying network stack reports a change (interface up/down, NAT change, roaming, etc.).