Documentation
    Preparing search index...

    Node-specific options accepted by createRelay, on top of the platform-agnostic RelayOptions.

    interface CreateRelayOptions {
        addrs?: string[];
        agentsReceivedCallback: AgentsReceivedCallback;
        enablePing?: boolean;
        id?: string;
        networkAccessBytes?: NetworkAccessBytes;
        networkAccessHandler: NetworkAccessHandler;
        peerConnectedCallback: PeerConnectedCallback;
        peerDisconnectedCallback?: PeerDisconnectedCallback;
        publicIp?: string;
    }

    Hierarchy (View Summary)

    Index

    Properties

    addrs?: string[]

    Listening addresses in "host:port" format (e.g. "0.0.0.0:4001").

    IPv6 addresses must use bracket notation: "[::]:4001".

    Defaults to defaultRelayListenAddrs.

    agentsReceivedCallback: AgentsReceivedCallback

    Called when agent-info bytes have been received from a peer.

    enablePing?: boolean

    Opt into the libp2p ping protocol (/ipfs/ping/1.0.0). Defaults to false.

    Ping is a transport-level liveness/RTT probe: a dialer sends a payload, the relay echoes it, and the dialer measures round-trip time. Useful for external monitoring of relay liveness, latency measurement before selecting a bootstrap relay, and keeping NAT/firewall mappings warm.

    Ping runs as a libp2p service handler, independent of the /peerkit/access/v1 gate: it is not blocked for peers that have not completed the network-access handshake, so external monitors can health- check the relay without holding NetworkAccessBytes.

    id?: string

    Optional human-readable identifier attached to log records.

    networkAccessBytes?: NetworkAccessBytes

    Network access bytes sent in handshake responses (and outbound handshakes for nodes).

    Defaults to new Uint8Array([0]) — an empty array breaks the counter-handshake because .send() would be a no-op.

    networkAccessHandler: NetworkAccessHandler

    Handler invoked for every incoming access handshake. Returns true to grant access, false to deny. Denials are sticky for the session.

    peerConnectedCallback: PeerConnectedCallback

    Called when an inbound peer completes the access handshake. Fire-and-forget.

    peerDisconnectedCallback?: PeerDisconnectedCallback

    Called when a peer disconnects. Fire-and-forget.

    publicIp?: string

    Public IP to announce when the relay is behind NAT.

    The transport computes /ip4/<ip>/tcp/<port>/ws (or /ip6/…) for each listen address and configures libp2p to advertise it. Peers dial the public address; the relay still binds locally to addrs.