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 8 additions and 8 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

@@ -33,7 +33,7 @@
"uuid": "^14.0.0",
"vue": "^3.5.32",
"vue-chartjs": "^5.3.3",
"vue-router": "^5.0.6"
"vue-router": "^5.0.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.6",
@@ -8488,9 +8488,9 @@
}
},
"node_modules/vue-router": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-5.0.6.tgz",
"integrity": "sha512-9+kmUTGbKMyW9Asoy98IXXYIzrTMT7JDAdpDDeEkorHvybpUvBI2wsrSM5jFOXrFydpzRFJ9vAh+80DN2PGu9w==",
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-5.0.4.tgz",
"integrity": "sha512-lCqDLCI2+fKVRl2OzXuzdSWmxXFLQRxQbmHugnRpTMyYiT+hNaycV0faqG5FBHDXoYrZ6MQcX87BvbY8mQ20Bg==",
"license": "MIT",
"dependencies": {
"@babel/generator": "^7.28.6",

View File

@@ -37,7 +37,7 @@
"uuid": "^14.0.0",
"vue": "^3.5.32",
"vue-chartjs": "^5.3.3",
"vue-router": "^5.0.6"
"vue-router": "^5.0.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.6",