Expand description
A UDP beacon address lookup, inspired by Zyre’s passive discovery beacon.
The beacon broadcasts a node’s current EndpointData (direct addresses and
an optional relay URL) as a small JSON datagram on a fixed UDP port. Unlike
mDNS there is no service-name registry; peers on the same LAN simply listen
on the same port and accept datagrams that carry the expected scope token.
Each configured network derives a 16-byte scope from its name. The scope is used twice:
- to derive the beacon port (the scope offsets the base port), and
- as a token inside every datagram so that different networks never accept each other’s beacons even when the derived ports collide.
This is an AddressLookup and can be registered next to the mDNS lookup.
Like mDNS it is a fallback for local discovery and is not an access
boundary: any peer that knows the derived port and scope can still be
reached, and membership is still enforced by the layer 2/3 peer allowlist.
Structs§
- Beacon
Address Lookup - An
AddressLookupthat publishes and resolves addresses over a UDP beacon.
Constants§
- BEACON_
MAGIC - Magic value that prefixes every beacon datagram. It both identifies the protocol and provides cheap sanity checking before JSON parsing.
- BEACON_
PEER_ TTL - How long a discovered peer’s addresses stay usable without a refresh.
- BEACON_
PORT_ SPREAD - Number of ports a scope may spread over when deriving the effective port.
- DEFAULT_
BEACON_ PORT - Default base UDP port for the beacon. The effective port is
base + (scope[0..2] % BEACON_PORT_SPREAD).
Functions§
- beacon_
port - Derives the effective beacon port for a scope.