Skip to main content

Module mdns

Module mdns 

Source
Expand description

mDNS-based peer discovery — an alternative path to the UDP broadcast fallback in discovery.rs for networks where broadcast traffic is filtered but multicast is not (some managed VLANs, cloud VPCs). Runs alongside UDP discovery rather than replacing it: callers typically merge results from both.

A Ghostlink node advertises itself as an instance of _ghostlink._tcp.local. with its NodeResources encoded as TXT record key/value pairs. Peers browse for that service type and decode the TXT records back into NodeResources.

Constants§

MDNS_SERVICE_TYPE
mDNS service type Ghostlink nodes advertise themselves under.

Functions§

discover
Browses for other Ghostlink nodes over mDNS for up to timeout, returning each resolved peer’s advertised resources and the address to reach it on. Blocks the calling thread for up to timeout — callers on an async runtime should run this via spawn_blocking, same as discovery::broadcast_and_collect.
ensure_advertised
Registers this node under MDNS_SERVICE_TYPE so LAN peers can find it via mDNS browsing, idempotently (subsequent calls are no-ops). Best-effort: a failure (e.g. multicast unavailable in a sandboxed/headless environment) is logged and otherwise ignored — mirrors how UDP discovery failures never block server startup elsewhere in this crate.