diff --git a/web/templates/vpn/index.html b/web/templates/vpn/index.html index 9927528..a65bdad 100644 --- a/web/templates/vpn/index.html +++ b/web/templates/vpn/index.html @@ -111,13 +111,12 @@ function fetch_keys() { }); var li = document.createElement('li'); li.innerHTML = ' ' + (new Date(key.time*1000).toISOString().split('T')[0]) + - ' ' + key.key + '' + - (key.active ? ' ' : ' ') + - key.name; + ' ' + key.key + ' ' + key.name + + (key.active ? ' ' : ''); li.prepend(a); keys.appendChild(li); if (key.active) - warning.innerHTML = 'Ta ključ uporablja aktivna povezava. Če ga odstranite, bo prekinjena.'; + warning.innerHTML = ' Ta ključ uporablja trenutna povezava. Če ga odstranite, bo prekinjena.'; } document.querySelector('section.keys').style.display = (Object.keys(data).length ? 'unset' : 'none'); }) diff --git a/web/vpn.py b/web/vpn.py index a1c46f3..086463e 100644 --- a/web/vpn.py +++ b/web/vpn.py @@ -22,7 +22,9 @@ def index(): @flask_login.login_required def list(): user = flask_login.current_user.get_id() - return flask.jsonify({k: v for k, v in db.load('wireguard').items() if v.get('user') == user}) + return flask.jsonify( + {k: v | {'active': flask.request.remote_addr in (v.get('ip'), v.get('ip6'))} + for k, v in db.load('wireguard').items() if v.get('user') == user}) @blueprint.route('/new', methods=('POST',)) @flask_login.login_required