discovery
discovery
¶
Discover already-paired Diapason devices without publishing identity.
mDNS is a hint, never a credential. Anyone on the current Wi-Fi can publish
an SRV record, so this module neither enrols a device nor writes a discovered
address to the registry. It only contacts a candidate whose rotating service
name can be derived from a public key learned during pairing. The peer then
answers with its own signed presence beacon; beacon.verify_beacon remains
the sole path that may retain the address.
The record deliberately contains no device id, hostname, owner id, platform, version or capability. Its instance label rotates hourly, which prevents the same laptop from advertising one durable tracking token in every café it visits.
Classes¶
DiscoveryUnavailable
¶
Bases: RuntimeError
The optional cross-platform mDNS implementation is not installed.
Advertisement
dataclass
¶
The complete public record — intentionally tiny and inspectable.
Functions:¶
service_token
¶
A 16-character rotating label known to already-paired devices only.
Source code in src/diapason/mesh/discovery.py
expected_names
¶
Map rotating labels to trusted local device ids.
The previous and next periods tolerate clock skew around the hour. A
revoked device disappears because public_key_of refuses to return its
key, even if an old row still exists in the database.
Source code in src/diapason/mesh/discovery.py
txt_properties
¶
current_advertisement
¶
current_advertisement(
*, now_ms: int | None = None
) -> Advertisement | None
Build what this process may truthfully advertise, or nothing.
No endpoint means the server has not promised a socket. Loopback, link-local and non-IP hosts are not advertised: a peer could not reach them through the transport policy, so publishing them would be a lie.
Source code in src/diapason/mesh/discovery.py
consider_candidate
¶
consider_candidate(
*,
name: str,
addresses: Iterable[str],
port: int,
properties: Mapping[bytes, bytes] | None,
registry: Any,
announce: Callable[..., bool],
now_ms: int,
) -> bool
Contact one authenticated-by-pairing candidate, without retaining it.
Source code in src/diapason/mesh/discovery.py
run_discovery
async
¶
Advertise and browse until the server lifespan cancels this task.
Source code in src/diapason/mesh/discovery.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |