From ece7cd18961bd29ec2e133e8fe0fea24bf25df26 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Sun, 10 May 2026 13:31:58 +0800 Subject: [PATCH] Use network_address for single-address IPs When parsing allowed_ip entries in API_ping_getAllPeersIpAddress(), detect networks with a single address (ip.num_addresses == 1) and append ip.network_address directly to the parsed list. This replaces the previous host-list construction (list(ip.hosts()) / host[0]) to simplify logic and avoid iterating hosts for /32 or single-address ranges while keeping existing error logging for invalid addresses. --- src/dashboard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index e04afadc..7b331b17 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1314,11 +1314,11 @@ def API_ping_getAllPeersIpAddress(): for x in allowed_ip: try: ip = ipaddress.ip_network(x, strict=False) + if ip.num_addresses == 1: + parsed.append(str(ip.network_address)) except ValueError as e: app.logger.error(f"Failed to parse IP address of {p.id} - {c.Name}") - host = list(ip.hosts()) - if len(host) == 1: - parsed.append(str(host[0])) + endpoint = p.endpoint.replace(" ", "").replace("(none)", "") if len(p.name) > 0: cips[f"{p.name} - {p.id}"] = {