This commit is contained in:
SiloDS
2021-07-30 13:27:35 +01:00
parent e362086ffe
commit ab9b2aa44b
3 changed files with 43 additions and 2 deletions

View File

@@ -155,3 +155,21 @@ def disconnect_network(ssid):
return False
return True
def vpn_connected():
if run_subprocess("nordvpn status").find("Disconnected") != -1:
return False
return True
def vpn_connect():
if run_subprocess("nordvpn c").find("connected to") != -1:
return True
return False
def vpn_disconnect():
if run_subprocess("nordvpn d").find("You are disconnected from NordVPN") != -1:
return True
return False

View File

@@ -4,14 +4,14 @@ from flask_login import current_user, login_required, login_user, logout_user
from app import app
from app.forms import LoginForm, WPAForm
from app.models import Passwords, User
from app.network_utils import scan_networks, connect_network, disconnect_network
from app.network_utils import scan_networks, connect_network, disconnect_network, vpn_connected, vpn_connect, vpn_disconnect
@app.route("/")
@app.route("/index")
@login_required
def index():
return render_template("index.html", networks=scan_networks())
return render_template("index.html", networks=scan_networks(), vpn=vpn_connected())
@app.route("/login", methods=["GET", "POST"])
@@ -69,3 +69,21 @@ def disconnect(ssid):
return render_template("message.html", message="Sucessfully disconnected from {}".format(ssid))
return render_template("message.html", message="Failt to disconnect from {}".format(ssid))
@app.route("/vpndconnect/", methods=["GET", "POST"])
@login_required
def vpnconnect():
if vpn_connect():
return render_template("message.html", message="Sucessfully Connected to VPN")
return render_template("message.html", message="Failed to Connect to VPN")
@app.route("/vpndisconnect/", methods=["GET", "POST"])
@login_required
def vpndisconnect():
if vpn_disconnect():
return render_template("message.html", message="Sucessfully disconnected from VPN")
return render_template("message.html", message="Failed to disconnect from VPN")

View File

@@ -47,6 +47,11 @@
{% if not current_user.is_anonymous %}
<a href="{{ url_for('logout') }}">Logout</a>
{% endif %}
{% if vpn %}
<a href="{{ url_for('vpndisconnect') }}">Disconnect</a>
{% else %}
<a href="{{ url_for('vpnconnect') }}">Connect</a>
{% endif %}
</div>
<hr>
{% block content %}{% endblock %}