Restart safety: transient credential checks are 1013/503, not a refusal
- A device credential that cannot be checked now (device store not running, nonces unreadable) raises DeviceUnavailable: 503 over HTTP, and the /flows/ws handshake and the tunnel stream accept and close with 1013. 1008 (a 403 before accepting) stays for a revoked or invalid one - Device files are written through a temporary file, so a read mid-save no longer looks like a deleted device - The first report turns Touch friendly on only for a device paired since pairings are noted (DeviceState.paired_at), so devices paired before keep the switch they were given - NodeDef reads `device`/`device_policy` from older clients as the worker label, for a release - Tests: transient vs revoked socket, the touch default, the old worker keys, and a restart with a device node and a node_health rule sending no push
This commit is contained in:
@@ -625,7 +625,8 @@ async def put_report(device_id: str, request: Request, store: DeviceStoreDep) ->
|
||||
|
||||
The first report of a touch screen makes the device touch friendly, as
|
||||
the switch would have been set by hand. Later ones leave the setting to
|
||||
whoever changed it since.
|
||||
whoever changed it since, and so does the first report of a device paired
|
||||
before pairings were noted: its switch was set by hand already.
|
||||
"""
|
||||
device: DeviceDef | None = getattr(request.state, "device", None)
|
||||
if device is None or device.id != device_id:
|
||||
@@ -650,7 +651,13 @@ async def put_report(device_id: str, request: Request, store: DeviceStoreDep) ->
|
||||
),
|
||||
)
|
||||
first = await run_in_threadpool(store.report, device_id, report)
|
||||
if first and report.display and report.display.touch and not device.touch:
|
||||
if (
|
||||
first
|
||||
and report.display
|
||||
and report.display.touch
|
||||
and not device.touch
|
||||
and (await run_in_threadpool(store.state, device_id)).paired_at
|
||||
):
|
||||
with suppress(StaleVersion, DeviceNotFound):
|
||||
await run_in_threadpool(
|
||||
store.write,
|
||||
@@ -724,6 +731,7 @@ def _adopt(
|
||||
)
|
||||
entry.device_id = device_id
|
||||
_pending.save(code, entry)
|
||||
store.paired(device_id)
|
||||
return f"Paired {entry.name or entry.device} with {device_id}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user