Skip to main content

Module beacon_lookup

Module beacon_lookup 

Source
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§

BeaconAddressLookup
An AddressLookup that 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.