Browse Source

Fixed bug where the first peer added to a new server, had colliding IP with the server

pull/5/head
Per-Arne 5 years ago
parent
commit
7926947224
  1. 9
      wg_dashboard_backend/routers/v1/peer.py

9
wg_dashboard_backend/routers/v1/peer.py

@ -23,7 +23,16 @@ def add_peer(
address_space = set(ipaddress.ip_network(server.address, strict=False).hosts()) address_space = set(ipaddress.ip_network(server.address, strict=False).hosts())
occupied_space = set() occupied_space = set()
# Try add server IP to list.
try:
occupied_space.add(ipaddress.ip_address(server.address.split("/")[0]))
except ValueError:
pass
for p in server.peers: for p in server.peers:
# Try add peer ip to list.
try: try:
occupied_space.add(ipaddress.ip_address(p.address.split("/")[0])) occupied_space.add(ipaddress.ip_address(p.address.split("/")[0]))
except ValueError as e: except ValueError as e:

Loading…
Cancel
Save