diff --git a/daemon/core/gui/interface.py b/daemon/core/gui/interface.py index 437bd37c..1973fe99 100644 --- a/daemon/core/gui/interface.py +++ b/daemon/core/gui/interface.py @@ -12,7 +12,9 @@ if TYPE_CHECKING: from core.gui.graph.node import CanvasNode -def get_index(interface: "core_pb2.Interface") -> int: +def get_index(interface: "core_pb2.Interface") -> Optional[int]: + if not interface.ip4: + return None net = netaddr.IPNetwork(f"{interface.ip4}/{interface.ip4mask}") ip_value = net.value cidr_value = net.cidr.value @@ -108,7 +110,8 @@ class InterfaceManager: self.used_subnets.pop(subnets.key(), None) else: index = get_index(interface) - subnets.used_indexes.discard(index) + if index is not None: + subnets.used_indexes.discard(index) self.current_subnets = None def joined(self, links: List["core_pb2.Link"]) -> None: @@ -123,6 +126,8 @@ class InterfaceManager: for interface in interfaces: subnets = self.get_subnets(interface) index = get_index(interface) + if index is None: + continue subnets.used_indexes.add(index) if subnets.key() not in self.used_subnets: self.used_subnets[subnets.key()] = subnets