pub struct IrohEndpoint { /* private fields */ }Expand description
A shared Iroh endpoint.
Clone-able (cheap Arc clone). All fetch and serve calls on the same node share one endpoint and therefore one stable QUIC identity.
Implementations§
Source§impl IrohEndpoint
impl IrohEndpoint
Sourcepub async fn bind(opts: NodeOptions) -> Result<Self, CoreError>
pub async fn bind(opts: NodeOptions) -> Result<Self, CoreError>
Bind an Iroh endpoint with the supplied options.
Source§impl IrohEndpoint
impl IrohEndpoint
Sourcepub async fn close(&self)
pub async fn close(&self)
Graceful close: signal the serve loop to stop accepting, wait for in-flight requests to drain, then close the QUIC endpoint.
Sourcepub async fn close_force(&self)
pub async fn close_force(&self)
Immediate close: abort the serve loop with no drain period.
Sourcepub async fn wait_closed(&self)
pub async fn wait_closed(&self)
Wait until this endpoint has been closed. Returns immediately if already closed.
Sourcepub fn set_serve_handle(&self, handle: ServeHandle)
pub fn set_serve_handle(&self, handle: ServeHandle)
Store a serve handle so that close() can drain it.
If stop_serve() was called before this (the JS abort raced ahead of
the napi async setup), the handle is immediately shut down so the
serve loop drains without a second stop_serve() call.
Sourcepub fn stop_serve(&self)
pub fn stop_serve(&self)
Signal the serve loop to stop accepting new connections.
Sourcepub async fn wait_serve_stop(&self)
pub async fn wait_serve_stop(&self)
Wait until the serve loop has fully exited.
Sourcepub fn subscribe_events(&self) -> Option<Receiver<TransportEvent>>
pub fn subscribe_events(&self) -> Option<Receiver<TransportEvent>>
Take the transport event receiver, handing it off to a platform drain task. May only be called once per endpoint.
Source§impl IrohEndpoint
impl IrohEndpoint
Sourcepub fn endpoint_stats(&self) -> EndpointStats
pub fn endpoint_stats(&self) -> EndpointStats
Snapshot of current endpoint statistics.
All fields are point-in-time reads and may change between calls.
Sourcepub fn bound_sockets(&self) -> Vec<SocketAddr>
pub fn bound_sockets(&self) -> Vec<SocketAddr>
Returns the local socket addresses this endpoint is bound to.
Sourcepub fn node_addr(&self) -> NodeAddrInfo
pub fn node_addr(&self) -> NodeAddrInfo
Full node address: node ID + relay URL(s) + direct socket addresses.
Sourcepub fn home_relay(&self) -> Option<String>
pub fn home_relay(&self) -> Option<String>
Home relay URL, or None if not connected to a relay.
Sourcepub async fn peer_info(&self, node_id_b32: &str) -> Option<NodeAddrInfo>
pub async fn peer_info(&self, node_id_b32: &str) -> Option<NodeAddrInfo>
Known addresses for a remote peer, or None if not in the endpoint’s cache.
Sourcepub async fn peer_stats(&self, node_id_b32: &str) -> Option<PeerStats>
pub async fn peer_stats(&self, node_id_b32: &str) -> Option<PeerStats>
Per-peer connection statistics.
Returns path information for each known transport address, including whether each path is via a relay or direct, and which is active.
Sourcepub fn subscribe_path_changes(
&self,
node_id_str: &str,
) -> UnboundedReceiver<PathInfo>
pub fn subscribe_path_changes( &self, node_id_str: &str, ) -> UnboundedReceiver<PathInfo>
Subscribe to path changes for a specific peer.
Spawns a background watcher task the first time a given peer is subscribed.
The watcher polls peer_stats() every 200 ms and emits on the returned
channel whenever the active path changes.
Source§impl IrohEndpoint
impl IrohEndpoint
Sourcepub fn secret_key_bytes(&self) -> [u8; 32]
pub fn secret_key_bytes(&self) -> [u8; 32]
The node’s raw secret key bytes (32 bytes).
§Security
These 32 bytes are the irrecoverable private key for this node. Anyone who obtains them can impersonate this node permanently. Never log, print, or include in error payloads. Encrypt at rest. Zeroize after use.
Sourcepub fn handles(&self) -> &HandleStore
pub fn handles(&self) -> &HandleStore
Per-endpoint handle store.
Sourcepub fn max_header_size(&self) -> usize
pub fn max_header_size(&self) -> usize
Maximum byte size of an HTTP/1.1 head.
Sourcepub fn max_response_body_bytes(&self) -> usize
pub fn max_response_body_bytes(&self) -> usize
Maximum decompressed response-body bytes accepted per outgoing fetch.
Sourcepub fn compression(&self) -> Option<&CompressionOptions>
pub fn compression(&self) -> Option<&CompressionOptions>
Compression options, if the compression feature is enabled.
Trait Implementations§
Source§impl Clone for IrohEndpoint
impl Clone for IrohEndpoint
Source§fn clone(&self) -> IrohEndpoint
fn clone(&self) -> IrohEndpoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for IrohEndpoint
impl !UnwindSafe for IrohEndpoint
impl Freeze for IrohEndpoint
impl Send for IrohEndpoint
impl Sync for IrohEndpoint
impl Unpin for IrohEndpoint
impl UnsafeUnpin for IrohEndpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more