feat(mazenet): auto-bridge new LANs to the DMZ gateway

When a non-DMZ LAN is created via POST /lans, look up the topology's
gateway (decky with forwards_l3=True attached to the DMZ) and insert
an edge binding it to the new LAN. The gateway becomes multi-homed
to every internal LAN automatically, so DMZ_ORPHAN cannot arise
from ordinary editor use.

Also fixes delete_lan: the home-decky guard used scalar_one_or_none,
which blew up when the gateway already had >1 'other' LAN edge.
Switch to scalars().first() — we only need to know *some* other
edge exists, not a unique one.
This commit is contained in:
2026-04-20 23:07:19 -04:00
parent 3618c59d08
commit be4e1b1891
2 changed files with 55 additions and 2 deletions

View File

@@ -1172,7 +1172,7 @@ class SQLModelRepository(BaseRepository):
TopologyEdge.lan_id != lan_id,
)
)
if other.scalar_one_or_none() is None:
if other.scalars().first() is None:
raise ValueError(
f"cannot delete LAN {lan.name!r}: decky "
f"{decky_uuid} has no other LAN (would be orphaned)"