EndpointInterface

An iroh endpoint.

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

Inheritors

Types

Link copied to clipboard
object Companion

Functions

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

Pull the next incoming connection attempt from the accept queue.

Link copied to clipboard
abstract suspend 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
abstract fun addr(): EndpointAddr

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

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

The local socket addresses this endpoint is bound to.

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

Connect to a remote endpoint via the given ALPN.

Link copied to clipboard
abstract suspend 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
abstract fun id(): EndpointId

The `EndpointId` of this endpoint.

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

Insert (or replace) a relay configuration at runtime.

Link copied to clipboard
abstract fun isClosed(): Boolean

Returns true if the endpoint has been closed.

Link copied to clipboard
abstract suspend fun online()

Resolves once the endpoint has a usable home relay.

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

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

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

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

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

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

Link copied to clipboard
abstract fun secretKey(): SecretKey

The `SecretKey` backing this endpoint's identity.

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

Replace the set of ALPNs advertised by this endpoint.

Link copied to clipboard
abstract suspend fun shutdown()

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

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

Get current statistics for this endpoint.

Link copied to clipboard
abstract 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

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.).