Compare commits

..

1 Commits

Author SHA1 Message Date
Donald Zou
ece7cd1896 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.
2026-05-10 13:31:58 +08:00
3 changed files with 12 additions and 14 deletions

View File

@@ -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}"] = {

View File

@@ -16,7 +16,7 @@
"animate.css": "^4.1.1",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.3",
"cidr-tools": "^11.3.5",
"cidr-tools": "^11.3.3",
"css-color-converter": "^2.0.0",
"dayjs": "^1.11.19",
"electron-builder": "^26.7.0",
@@ -2360,15 +2360,14 @@
}
},
"node_modules/cidr-tools": {
"version": "11.3.5",
"resolved": "https://registry.npmjs.org/cidr-tools/-/cidr-tools-11.3.5.tgz",
"integrity": "sha512-cu6KcxIZRKlvcTrMWbUZU6LQ/mKSUNhjktDpgSZASoUF7pAJPk038BtwOIgCpbtjfOLpAWCh/y8+sE6YCEIXxw==",
"version": "11.3.3",
"resolved": "https://registry.npmjs.org/cidr-tools/-/cidr-tools-11.3.3.tgz",
"integrity": "sha512-3fHQpk8DxUjO/nuoo9gTDpOKQDHoHarCxU3b7bkAq/nMHm54ADqoSQRF3l/GVbnOEtt5wfo/3vTEp4imLb7BZQ==",
"license": "BSD-2-Clause",
"dependencies": {
"ip-bigint": "^8.3.6"
"ip-bigint": "^8.3.4"
},
"engines": {
"bun": "*",
"node": ">=18"
}
},
@@ -3793,12 +3792,11 @@
}
},
"node_modules/ip-bigint": {
"version": "8.3.6",
"resolved": "https://registry.npmjs.org/ip-bigint/-/ip-bigint-8.3.6.tgz",
"integrity": "sha512-IRan4ty1RP2aI0MDQtfEs6gGtjDLb/4808xm21BK+ytLquz8FLiWQlepONVcQycjku3HPPEPPUcg9Om8hdOzJQ==",
"version": "8.3.4",
"resolved": "https://registry.npmjs.org/ip-bigint/-/ip-bigint-8.3.4.tgz",
"integrity": "sha512-W34SH99LpEuCGlX+pv5EM8m57EMfm01o19Os2oQEHsmQVkHcIHtAU/YfpGFTAzUqM65e3GKA1JK/bHhNL1Ag4Q==",
"license": "BSD-2-Clause",
"engines": {
"bun": "*",
"node": ">=18"
}
},

View File

@@ -20,7 +20,7 @@
"animate.css": "^4.1.1",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.3",
"cidr-tools": "^11.3.5",
"cidr-tools": "^11.3.3",
"css-color-converter": "^2.0.0",
"dayjs": "^1.11.19",
"electron-builder": "^26.7.0",