feat(network): integrate NetBird clients, profiles and private backups
This commit is contained in:
@@ -21,6 +21,7 @@ from missioncore_plugin_sdk.v0alpha2.identity import ExecutionBinding
|
||||
|
||||
from . import sensors
|
||||
from .channel_binding import authenticate, endpoint_error
|
||||
from .recovery import listener_addresses
|
||||
from .sensor_transient import cache as sensor_transient
|
||||
from .trust import SCHEMA, CoreTrust, PairingError, node_request, parse_invitation, pem, public_id
|
||||
|
||||
@@ -57,6 +58,8 @@ class FleetRegistry:
|
||||
self.trust = CoreTrust(root)
|
||||
from .network_profiles import NetworkProfiles
|
||||
self.network_profiles = NetworkProfiles(self)
|
||||
from .netbird.client import Client as NetBirdClient
|
||||
self.netbird = NetBirdClient(root)
|
||||
path = root / "fleet.sqlite3"
|
||||
if path.is_symlink():
|
||||
raise PairingError("Конфликт файла реестра.")
|
||||
@@ -123,9 +126,10 @@ class FleetRegistry:
|
||||
with self.lock:
|
||||
for row in self.rows():
|
||||
if row["enrollment"] in ("pending", "paired"):
|
||||
# Address absent: keep the binding and show offline.
|
||||
with suppress(OSError):
|
||||
self.listen(row["core_address"])
|
||||
# Address absent: preserve trust and retry saved listeners.
|
||||
for address in listener_addresses(row):
|
||||
with suppress(OSError):
|
||||
self.listen(address)
|
||||
for profile in self.network_profiles.profiles.values():
|
||||
if profile.get("state") == "ready":
|
||||
import ipaddress
|
||||
@@ -147,6 +151,7 @@ class FleetRegistry:
|
||||
|
||||
def close(self):
|
||||
self.stop.set()
|
||||
self.netbird.close()
|
||||
if self.vps_hosts is not None:
|
||||
self.vps_hosts.close()
|
||||
if self.worker:
|
||||
@@ -423,7 +428,7 @@ class FleetRegistry:
|
||||
with self.lock:
|
||||
self.routers.prune()
|
||||
active = [row for row in self.rows() if row["enrollment"] in ("pending", "paired")]
|
||||
for address in {row["core_address"] for row in active}:
|
||||
for address in {address for row in active for address in listener_addresses(row)}:
|
||||
try:
|
||||
self.listen(address)
|
||||
server = self.listeners[address]
|
||||
|
||||
Reference in New Issue
Block a user