Add packaged Insta360 X4 integration and recover paired Node channels
Discover independent camera instances and prepare their versioned runtime from Node or remote Core. Add isolated SDK workers, camera controls, raw dual-fisheye WebRTC preview, and shared action/region loading states. Recover existing Node bindings over known Tailscale addresses after a Core LAN address change. Preserve identities and trust, pin both peers, migrate endpoints with revision checks, and require real heartbeats for online status. Fix the Python client certificate profile for Go X509 verification. Pin Design Guideline 8c53f73 and retain installer/build/acceptance history. Node 0.8.19 is installed; X4 0.1.3-3 is bundled but hardware activation is pending. Validation: qualified DG/Node builds and Go race tests; 31 fleet tests; Python-to-Go certificate interoperability and live tailnet recovery with five fresh heartbeats; prior 38 X4 tests and bounded remote WebRTC acceptance. Clean-OS, replug/power autonomy, local X4 video and long-run stability remain open.
This commit is contained in:
@@ -54,6 +54,7 @@ class FleetRegistry:
|
||||
self.listeners: dict[str, object] = {}
|
||||
self.stop = threading.Event()
|
||||
self.worker: threading.Thread | None = None
|
||||
self.recovery_worker: threading.Thread | None = None
|
||||
|
||||
def rows(self):
|
||||
return [
|
||||
@@ -86,11 +87,22 @@ class FleetRegistry:
|
||||
target=self.reconcile, name="mission-core-fleet", daemon=True
|
||||
)
|
||||
self.worker.start()
|
||||
from .recovery import reconcile as recover_channels
|
||||
|
||||
self.recovery_worker = threading.Thread(
|
||||
target=recover_channels,
|
||||
args=(self,),
|
||||
name="mission-core-channel-recovery",
|
||||
daemon=True,
|
||||
)
|
||||
self.recovery_worker.start()
|
||||
|
||||
def close(self):
|
||||
self.stop.set()
|
||||
if self.worker:
|
||||
self.worker.join(timeout=20)
|
||||
if self.recovery_worker:
|
||||
self.recovery_worker.join(timeout=30)
|
||||
for server in self.listeners.values():
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
@@ -341,7 +353,7 @@ class FleetRegistry:
|
||||
self.save(row)
|
||||
self.stop.wait(2)
|
||||
|
||||
def receive(self, certificate: bytes, path: str, value: dict):
|
||||
def receive(self, certificate: bytes, path: str, value: dict, *, address: str | None = None):
|
||||
cert = x509.load_der_x509_certificate(certificate)
|
||||
key = cert.public_key()
|
||||
if not isinstance(key, Ed25519PublicKey):
|
||||
@@ -380,6 +392,25 @@ class FleetRegistry:
|
||||
return 200, {"ok": True}
|
||||
if path != "/v1/node/heartbeat":
|
||||
return 404, {"error": "Unknown operation"}
|
||||
# Endpoint revisions prevent an old in-flight heartbeat or lost ack
|
||||
# from reversing a migration. Use the actual listener, not a claimed IP.
|
||||
from .recovery import tailnet_address
|
||||
|
||||
revision = value.get("endpoint_revision", 0)
|
||||
if type(revision) is not int or not 0 <= revision <= 1000000000:
|
||||
return 400, {"error": "Invalid endpoint revision"}
|
||||
previous_revision = row["binding"].get("endpoint_revision", 0)
|
||||
if revision < previous_revision:
|
||||
return 409, {"error": "Endpoint superseded"}
|
||||
if revision > previous_revision:
|
||||
if (
|
||||
not tailnet_address(address)
|
||||
or value.get("core_endpoint") != f"https://{address}:8782"
|
||||
):
|
||||
return 400, {"error": "Endpoint does not match authenticated channel"}
|
||||
row["core_address"] = address
|
||||
row["binding"]["endpoint"] = value["core_endpoint"]
|
||||
row["binding"]["endpoint_revision"] = revision
|
||||
binding = ExecutionBinding.model_validate(value["execution_binding"])
|
||||
if binding.node_id != node_id or binding.platform.value != "linux":
|
||||
return 400, {"error": "Invalid Node inventory"}
|
||||
@@ -417,4 +448,10 @@ class FleetRegistry:
|
||||
except (ValueError, TypeError, KeyError, sqlite3.Error):
|
||||
# Telemetry persistence failure must not block device control.
|
||||
pass
|
||||
return 200, {"monitor_ack": monitor_ack, "ok": True, "client_pem": row["binding"]["client_pem"], **sensor_response, **enrollment_response}
|
||||
return 200, {
|
||||
"monitor_ack": monitor_ack,
|
||||
"ok": True,
|
||||
"client_pem": row["binding"]["client_pem"],
|
||||
**sensor_response,
|
||||
**enrollment_response,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user