Creates an AutoInterface. Discovery sockets are opened by connect.
Optionaloptions: AutoInterfaceOptions = {}Protected_Whether a terminal closed event has already been dispatched for the
current connection episode (dedupe guard).
Protected_AbortController for the current reconnect wait, so disconnect() can
cancel an in-flight backoff immediately.
Protected_Reconnect attempt counter for the current drop episode. Reset to 0 at the start of each Interface._runReconnectLoop run.
Protected_Single-flight guard: only one reconnect loop runs at a time.
Whether automatic reconnection is enabled for this initiator interface.
Set whenever peer/link state changes a way that should reset announce-rate control.
Per-dial connect timeout in seconds.
Permanent stop signal read by the reconnect loop. Set by disconnect().
Whether this interface is the initiator (the outbound dialer). Only
initiators reconnect; adopted/server-spawned sockets never do (matching
the Python reference initiator flag).
Maximum reconnection attempts per drop. Infinity retries forever.
Multi-interface dedup deque: recent data-packet hashes with their expiry. Capped at MULTI_IF_DEQUE_LEN entries; a hit within MULTI_IF_DEQUE_TTL drops a duplicate seen on another interface.
Seconds to wait between reconnection attempts.
The underlying socket, when this interface is backed by a Node.js stream.
Transport that owns this interface, set via attachTransport. When
present, spawned peers are auto-registered with it; otherwise the caller
registers them via the "connection" event.
Number of spawned peer data interfaces. Mirrors Python's
len(self.spawned_interfaces) (the count used for peer_count).
The parent AutoInterface has no RNS byte stream of its own — it only
spawns per-peer interfaces that do. Returns null (rather than throwing)
so TransportCore.addInterface can attach the parent to receive the
transport ref via attachTransport without trying to grab a writer.
Protected_Protected
Signals the reconnect loop to stop and cancels any in-flight backoff.
Client subclasses call this at the top of their disconnect().
Protected_Protected
Dispatches a terminal closed event exactly once per connection episode.
Protected_Protected
Dials the peer and sets up the RNS streams, resolving once connected and
dispatching connected. Implemented by reconnect-capable client
subclasses; used both for the initial connection and each reconnect
attempt by the shared Interface._runReconnectLoop.
Protected_Protected
Called when the underlying connection drops (the inbound stream ends or
errors). For an initiator with auto-reconnect enabled and not deliberately
detached, dispatches disconnected and kicks off the reconnect loop;
otherwise dispatches a terminal closed event.
Matches the Python reference read_loop, which reconnects the initiator
on any termination and tears down (non-reconnecting) everyone else.
Protected_Protected
Initializes shared reconnect state from constructor options. Called by client interface subclasses (TCP, WebSocket) that support reconnection.
Subclasses must also set Interface.initiator: true for an
outbound dialer, false for an adopted/server-spawned socket.
Decides whether an interface should be adopted, mirroring the Python reference's per-interface skip chain.
When an allow-list (AutoInterface.allowedInterfaces, devices) is
set, only those names are adopted, and they bypass the ignore lists
(including loopback) — matching Python's
if len(allowed) > 0 and not ifname in allowed: skip, with the same
relaxation that lets the single-host loopback smoketest pin lo0
explicitly. (Python unconditionally skips lo0 on Darwin even when
allowed; we relax only that, so production parity holds: loopback is never
adopted without devices.)
Multi-interface dedup check. Returns true (and remembers nothing) if the
packet hash was seen within MULTI_IF_DEQUE_TTL; otherwise remembers
it and returns false. Mirrors Python's mif_deque/mif_deque_times logic.
SHA-256 of the raw datagram bytes.
true if the packet is a recent duplicate.
Monotonic-ish wall-clock seconds, mirroring Python's time.time().
Protected_Protected
Authenticates an inbound discovery datagram and, on success, records the
peer. Verifies that the first HASHLENGTH_BYTES bytes equal
SHA-256(group_id || src_addr), exactly as Python's discovery_handler
does. Self-multicast-echoes (src is one of our own link-local addresses)
feed the carrier watchdog state instead of adding a peer.
Protected_Protected
One peer-jobs tick. Expires silent peers (and tears down their spawned
interfaces), sends reverse-peering packets to peers due for one, rebinds
the per-interface data socket when its link-local address changes, and runs
the multicast-echo carrier watchdog. Mirrors Python's peer_jobs.
Protected_Protected
Runs the single-flight reconnect loop. Repeatedly waits reconnectWait
seconds then attempts to re-establish the connection via the subclass
_establishConnection() hook, until it succeeds, the interface is
detached, or maxReconnectTries is exceeded (terminal closed).
Each attempt fires a reconnecting event with the upcoming attempt
number, the wait, and the cap, for observability. A successful reconnect
fires connected (via _establishConnection).
Sends a raw RNS packet to a peer on the given interface, from that
interface's data socket. The destination is re-scoped with %ifname so the
OS routes it out the correct link-local. Mirrors Python's
AutoInterfacePeer.process_outgoing send path (Python uses a shared
unbound outbound socket + addr%ifindex; we reuse the per-interface bound
data socket, which already has the correct source address).
Descope'd peer link-local address.
Protected_Protected
Resolves after ms, or immediately if signal aborts. Used so
disconnect() can cancel an in-flight reconnect backoff at once.
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optionaloptions: boolean | AddEventListenerOptionsRecords a discovered peer, or refreshes a known one, mirroring Python's
add_peer. For a new peer this spawns an AutoInterfacePeer data
interface, registers it with the attached transport (if any), and dispatches
a "connection" event with the peer for parity with the other server
interfaces.
If addr is one of our own link-local addresses, this is our own multicast
echo: it feeds the carrier watchdog (multicastEchoes/initialEchoes)
rather than adding a peer.
Descope'd source link-local address.
Receives the owning transport from TransportCore.addInterface so spawned
peers can be auto-registered (Open Q1 of work doc #12). Also registers any
peers spawned before the transport was attached, so the
addInterface/connect call order doesn't matter.
Enumerates, adopts suitable interfaces, opens the per-interface multicast +
unicast discovery sockets, and starts the announce loop and receive
handlers. Resolves once all adopted interfaces are listening and dispatches
"connected".
The discovery address and per-interface tokens are derived lazily here
(rather than in the constructor) because Identity.fullHash is async.
Closes all discovery and data sockets, stops the announce loops,
disconnects every spawned peer (which dispatches "closed" so an attached
transport removes it), drops all tracking state, and dispatches
"closed".
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
Refreshes a known peer's last-heard timestamp.
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionaloptions: boolean | EventListenerOptionsStaticgetReturns the JSON Schema describing the options accepted by the AutoInterface constructor, for dynamically-generated setup UIs.
A JSON Schema object.
AutoInterface — zero-config IPv6-multicast local-network peering.
Phases 1–3 of work doc #12: discovery + peer tracking (1), the data path (2), and the lifecycle jobs — peer expiry, reverse-peering send, link-local rebind, multicast-echo watchdog (3). Phase 4 (register in the interface registry; schema already present) remains. (
AutoInterfacePeer) and registering it with a transport arrives in Phase 2; the lifecycle jobs (expiry, reverse-peering send, rebind, watchdog) arrive in Phase 3.The parent interface dispatches:
"connected"once discovery sockets are up,"peer"with{ address, ifname }when a new peer is authenticated (Phase 2 will additionally spawn a peer interface and dispatch"connection"),"closed"ondisconnect(),"error"on socket errors.