beacon
beacon
¶
How a device says « je suis là » to the rest of the fleet.
Until now presence could only be recorded by whoever held this machine's API key — which is to say, by this machine about itself. That made every remote device's presence a fiction, and the whole honest-about-offline machinery had nothing true to stand on: a command could be reported as sent to a device that had been unplugged for a week.
A device announces itself with the same credential it uses to command: an Ed25519 signature over the envelope, verified against the public key recorded when it was paired. No API key is involved, because a joining device never has one.
Replay is stopped by monotonicity rather than by nonces. A heartbeat every fifteen seconds would mint 5 760 nonces per device per day to protect a message whose entire content is "still here"; storing one integer per device and refusing anything not strictly newer costs nothing and refuses the same attack — an attacker replaying a captured beacon cannot make a device that is off look on.
Classes¶
PresenceRejected
¶
Functions:¶
build_beacon
¶
build_beacon(
*,
owner_id: str,
device_id: str,
app_state: str = "",
transport: str = "lan",
address: str = "",
capabilities: tuple[str, ...] | list[str] | None = None,
app_version: str = "",
now: int | None = None,
) -> dict[str, Any]
The unsigned envelope, with keys in the order they are signed.
Source code in src/diapason/mesh/beacon.py
sign_beacon
¶
Sign with THIS device's private key.
Source code in src/diapason/mesh/beacon.py
verify_beacon
¶
verify_beacon(
raw: Mapping[str, Any],
*,
registry: Any,
local_owner_id: str,
local_device_id: str,
now: int | None = None,
) -> dict[str, Any]
Decide whether to believe raw, and return the accepted device row.
Check order mirrors verify_command: cheap structural checks first,
cryptography once the envelope is plausible, and the monotonicity clock
advanced LAST — a beacon rejected for another reason must not move the
watermark that the legitimate device still needs to clear.
Source code in src/diapason/mesh/beacon.py
announce_to
¶
announce_to(
device: Mapping[str, Any],
*,
address: str = "",
app_state: str = "",
timeout_s: float = 4.0,
post=None,
) -> bool
Tell one peer we are here. False on any failure — never raises.
A beacon that does not arrive is not an error the user should hear about: the peer will simply consider us offline, which is what the honest-presence rules are designed to handle.
Source code in src/diapason/mesh/beacon.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
announce_to_fleet
¶
Announce to every trusted peer whose address we know.
Source code in src/diapason/mesh/beacon.py
set_local_endpoint
¶
local_endpoint
¶
Le socket réellement promis par le processus, sans le deviner.
None avant que la commande serve ait choisi ses sockets. La
découverte refuse alors de publier : annoncer un port supposé serait
exactement la panne que set_local_endpoint a été créé pour éviter.
Source code in src/diapason/mesh/beacon.py
local_address
¶
The address at which peers can really reach this machine.
A server bound to loopback advertises loopback, even though a LAN address would look more useful: peers off this machine genuinely cannot reach it, and telling them otherwise would send commands into the void and have them reported as delivered.