diff --git a/src/api.py b/src/api.py index da40482..1ab4493 100644 --- a/src/api.py +++ b/src/api.py @@ -66,6 +66,9 @@ class addConfiguration: for i in configs: if i['port'] == port: 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 def NameCheck(self, data, configs): diff --git a/src/dashboard.py b/src/dashboard.py index b640f1d..c9c9d4a 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -607,19 +607,32 @@ def f_available_ips(config_name): """ config_interface = read_conf_file_interface(config_name) if "Address" in config_interface: + available = [] existed = [] conf_address = config_interface['Address'] address = conf_address.split(',') for i in address: 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() for i in peers: add = i[0].split(",") for k in add: a, s = k.split("/") 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: try: available.remove(i) diff --git a/src/templates/index.html b/src/templates/index.html index 3ccb63f..783c996 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -9,7 +9,7 @@ {% include "navbar.html" %}
{% include "sidebar.html" %} -
+

Home