Expand description
LAN discovery: the opaque, rotating advertisement and the Discovery seam.
Discovery is the one genuinely new mechanism peering introduces. Devices advertise a
peering service over mDNS and accept connections over TCP. mDNS broadcasts are
visible to every host on the segment, so the advertisement must not leak identity: a
device advertises an OpaqueAdvertisement — a rotated opaque instance name — never
user@server.tld or a device name. Whether two advertisements belong to the same user is
established inside the encrypted channel, never from the broadcast.
The live mDNS responder is intentionally not built into this change: it is inherently
non-deterministic (real multicast, real timing) and belongs behind the Discovery seam,
exactly as the connection-class detector kept live NIC probing behind a signal seam. Tests
drive a MockDiscovery; a production responder — pure-Rust mdns-sd is the sanctioned
choice — implements Discovery over the same OpaqueAdvertisement descriptor.
Structs§
- Discovered
Peer - A peer found on the LAN: its opaque instance name and the socket to dial.
- Mock
Discovery - A deterministic in-memory
Discoveryfor tests: a shared registry of advertised peers. Cloning shares the registry, so a test can advertise on one handle and browse on another — standing in for two devices on the same segment. - Opaque
Advertisement - A LAN peering advertisement: an opaque, rotating service-instance name plus the TCP port the device listens on. The name is derived purely from a per-device rotation secret and a rotation epoch, so structurally there is no user handle or device name to leak.
- Rotation
Epoch - The rotation epoch an advertisement is derived for: the boot it was made in and the UTC day.
Constants§
- SERVICE_
TYPE - The mDNS service type peering advertises under. A fixed, non-identifying label shared by every Capsule device — it says “a Capsule peer is here”, nothing about who.
Traits§
- Discovery
- The LAN discovery seam. Abstracted so the (non-deterministic, multicast) mDNS responder is
mocked in tests while a production
mdns-sd-backed implementation plugs in unchanged. A device both advertises its own opaque service and browses for peers; peering is best-effort, so a browse that finds nothing simply returns an empty list.
Functions§
- new_
boot_ id - A fresh random per-boot identifier — what a device draws once at boot and feeds to
rotation_epochfor the life of that boot. - rotation_
epoch - Compute the rotation epoch from a per-boot identifier and the current UTC time.