mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-05-13 23:06:20 +00:00
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.
This commit is contained in:
@@ -1314,11 +1314,11 @@ def API_ping_getAllPeersIpAddress():
|
|||||||
for x in allowed_ip:
|
for x in allowed_ip:
|
||||||
try:
|
try:
|
||||||
ip = ipaddress.ip_network(x, strict=False)
|
ip = ipaddress.ip_network(x, strict=False)
|
||||||
|
if ip.num_addresses == 1:
|
||||||
|
parsed.append(str(ip.network_address))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
app.logger.error(f"Failed to parse IP address of {p.id} - {c.Name}")
|
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)", "")
|
endpoint = p.endpoint.replace(" ", "").replace("(none)", "")
|
||||||
if len(p.name) > 0:
|
if len(p.name) > 0:
|
||||||
cips[f"{p.name} - {p.id}"] = {
|
cips[f"{p.name} - {p.id}"] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user