mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
Update dashboard.py
- Fixed a bug where a peer without last handshake date was showing wrong date in webui - Hidden and temp conf files will be excluded from interfaces list
This commit is contained in:
parent
742191111b
commit
44f013a678
@ -137,7 +137,7 @@ def get_conf_peers_data(config_name):
|
|||||||
|
|
||||||
peer_data[data_usage[count]]['endpoint'] = data_usage[count + 1]
|
peer_data[data_usage[count]]['endpoint'] = data_usage[count + 1]
|
||||||
count += 2
|
count += 2
|
||||||
|
|
||||||
# Get latest handshakes
|
# Get latest handshakes
|
||||||
try:
|
try:
|
||||||
data_usage = subprocess.check_output("wg show " + config_name + " latest-handshakes", shell=True)
|
data_usage = subprocess.check_output("wg show " + config_name + " latest-handshakes", shell=True)
|
||||||
@ -156,9 +156,12 @@ def get_conf_peers_data(config_name):
|
|||||||
else:
|
else:
|
||||||
peer_data[data_usage[count]]['status'] = "stopped"
|
peer_data[data_usage[count]]['status'] = "stopped"
|
||||||
status = "stopped"
|
status = "stopped"
|
||||||
|
if (int(data_usage[count + 1]) > 0):
|
||||||
db.update({"latest_handshake": str(minus).split(".")[0], "status": status}, peers.id == data_usage[count])
|
db.update({"latest_handshake": str(minus).split(".")[0], "status": status}, peers.id == data_usage[count])
|
||||||
peer_data[data_usage[count]]['latest_handshake'] = str(minus).split(".")[0]
|
peer_data[data_usage[count]]['latest_handshake'] = str(minus).split(".")[0]
|
||||||
|
else:
|
||||||
|
db.update({"latest_handshake": "(None)", "status": status}, peers.id == data_usage[count])
|
||||||
|
peer_data[data_usage[count]]['latest_handshake'] = "(None)"
|
||||||
count += 2
|
count += 2
|
||||||
|
|
||||||
# Get allowed ip
|
# Get allowed ip
|
||||||
@ -226,14 +229,15 @@ def get_conf_status(config_name):
|
|||||||
def get_conf_list():
|
def get_conf_list():
|
||||||
conf = []
|
conf = []
|
||||||
for i in os.listdir(conf_location):
|
for i in os.listdir(conf_location):
|
||||||
if ".conf" in i:
|
if not i.startswith('.'):
|
||||||
i = i.replace('.conf', '')
|
if ".conf" in i:
|
||||||
temp = {"conf": i, "status": get_conf_status(i), "public_key": get_conf_pub_key(i)}
|
i = i.replace('.conf', '')
|
||||||
if temp['status'] == "running":
|
temp = {"conf": i, "status": get_conf_status(i), "public_key": get_conf_pub_key(i)}
|
||||||
temp['checked'] = 'checked'
|
if temp['status'] == "running":
|
||||||
else:
|
temp['checked'] = 'checked'
|
||||||
temp['checked'] = ""
|
else:
|
||||||
conf.append(temp)
|
temp['checked'] = ""
|
||||||
|
conf.append(temp)
|
||||||
conf = sorted(conf, key=itemgetter('status'))
|
conf = sorted(conf, key=itemgetter('status'))
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
@ -241,10 +245,11 @@ def get_conf_list():
|
|||||||
def get_running_conf_list():
|
def get_running_conf_list():
|
||||||
conf = []
|
conf = []
|
||||||
for i in os.listdir(conf_location):
|
for i in os.listdir(conf_location):
|
||||||
if ".conf" in i:
|
if not i.startswith('.'):
|
||||||
i = i.replace('.conf', '')
|
if ".conf" in i:
|
||||||
if get_conf_status(i) == "running":
|
i = i.replace('.conf', '')
|
||||||
conf.append(i)
|
if get_conf_status(i) == "running":
|
||||||
|
conf.append(i)
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
@ -372,4 +377,4 @@ if __name__ == "__main__":
|
|||||||
app.run(host='0.0.0.0', debug=False, port=10086)
|
app.run(host='0.0.0.0', debug=False, port=10086)
|
||||||
# for i in get_running_conf_list():
|
# for i in get_running_conf_list():
|
||||||
# p = Process(target=get_conf_peers_data, args=(i,))
|
# p = Process(target=get_conf_peers_data, args=(i,))
|
||||||
# p.start()
|
# p.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user