1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-06 16:00:28 +01:00

IPv6 configuration IP should be working now

This commit is contained in:
Donald Cheng Hong Zou 2022-03-29 15:11:50 -04:00
parent 337c9bc01e
commit 5af2fff9ca
3 changed files with 19 additions and 3 deletions

View File

@ -66,6 +66,9 @@ class addConfiguration:
for i in configs: for i in configs:
if i['port'] == port: if i['port'] == port:
return {"status": False, "reason": f"{port} used by {i['conf']}."} return {"status": False, "reason": f"{port} used by {i['conf']}."}
checkSystem = subprocess.run(f'ss -tulpn | grep :{port} > /dev/null', shell=True)
if checkSystem.returncode != 1:
return {"status": False, "reason": f"Port {port} used by other process in your system."}
return good return good
def NameCheck(self, data, configs): def NameCheck(self, data, configs):

View File

@ -607,19 +607,32 @@ def f_available_ips(config_name):
""" """
config_interface = read_conf_file_interface(config_name) config_interface = read_conf_file_interface(config_name)
if "Address" in config_interface: if "Address" in config_interface:
available = []
existed = [] existed = []
conf_address = config_interface['Address'] conf_address = config_interface['Address']
address = conf_address.split(',') address = conf_address.split(',')
for i in address: for i in address:
add, sub = i.split("/") add, sub = i.split("/")
existed.append(ipaddress.ip_address(add)) existed.append(ipaddress.ip_address(add.replace(" ", "")))
peers = g.cur.execute("SELECT allowed_ip FROM " + config_name).fetchall() peers = g.cur.execute("SELECT allowed_ip FROM " + config_name).fetchall()
for i in peers: for i in peers:
add = i[0].split(",") add = i[0].split(",")
for k in add: for k in add:
a, s = k.split("/") a, s = k.split("/")
existed.append(ipaddress.ip_address(a.strip())) existed.append(ipaddress.ip_address(a.strip()))
available = list(ipaddress.ip_network(address[0], False).hosts()) count = 0
for i in address:
tmpIP = ipaddress.ip_network(i.replace(" ", ""), False)
if tmpIP.version == 6:
for i in tmpIP.hosts():
if i not in existed:
available.append(i)
count += 1
if count > 100:
break
else:
available = available + list(tmpIP.hosts())
for i in existed: for i in existed:
try: try:
available.remove(i) available.remove(i)

View File

@ -9,7 +9,7 @@
{% include "navbar.html" %} {% include "navbar.html" %}
<div class="container-fluid"> <div class="container-fluid">
{% include "sidebar.html" %} {% include "sidebar.html" %}
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 mb-4"> <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4 mb-4" style="margin-bottom: 10rem !important;">
<div style="display: flex; flex-direction: row; align-items: center;"> <div style="display: flex; flex-direction: row; align-items: center;">
<h1 class="pb-4 mt-4">Home</h1> <h1 class="pb-4 mt-4">Home</h1>
</div> </div>