Skip to main content

connect

Function connect 

Source
pub async fn connect(
    peer: &PeerTarget,
    identity: &LocalIdentity,
    config: &NatConfig,
) -> Result<PeerConnection, NatError>
Expand description

Establish a mutually-authenticated connection to peer, choosing the traversal method transparently (first success wins; relay is the last resort).

identity is this node’s mTLS identity (its client certificate + key); config selects which methods are enabled + the per-method timeout + the relay/STUN endpoints. On success the returned PeerConnection carries the verified remote peer_id, the TraversalKind that established it, and the authenticated stream.

§Errors

This function never panics and never hangs: every method (and its dial) is bounded by NatConfig::per_method_timeout.