def wifi(): form = wifiForm() if request.method == "GET": return render_template("wifi.html", form=form) elif request.method == "POST": if form.validate(): ssid = form.ssid.data.rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) time.sleep(5) if internet_status() is True: restart_vpn() time.sleep(5) flash("Wifi settings saved! VPN Restarted!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("wifi.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("wifi.html", form=form)
def wifi(): form = wifiForm() if(request.method == "GET"): return render_template("wifi.html", form=form) elif(request.method == "POST"): if(form.validate()): ssid = (form.ssid.data).rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) time.sleep(5) if(internet_status() == True): restart_vpn() time.sleep(5) flash("Wifi settings saved! VPN Restarted!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("wifi.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("wifi.html", form=form)
def initial_setup(): form = initialSetupForm() if request.method == "GET": return render_template("initial_setup.html", form=form) elif request.method == "POST": if form.validate(): ssid = form.ssid.data.rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) if internet_status() is True: vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() flash("Wifi and VPN settings saved!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("initial_setup.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("initial_setup.html", form=form)
def initial_setup(): form = initialSetupForm() if(request.method == "GET"): return render_template("initial_setup.html", form=form) elif(request.method == "POST"): if(form.validate()): ssid = (form.ssid.data).rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) if(internet_status() == True): vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() flash("Wifi and VPN settings saved!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("initial_setup.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("initial_setup.html", form=form)
def status(): form = statusForm() if request.method == "GET": # check to see if network and vpn are active, red=not active, green=active internet_status_color = "green" if internet_status() else "red" vpn_status_color = "green" if vpn_status() else "red" return render_template("status.html", form=form, internet_status_color=internet_status_color, vpn_status_color=vpn_status_color)
def login(): form = loginForm() if (request.method == "GET"): return render_template("login.html", form=form) elif (request.method == "POST"): if (form.validate()): username = form.username.data password = form.password.data if (user_validate_credentials(username, password)): user = User() user.id = username flask_login.login_user(user) #check to see if default credentials are being used. If so, redirect to change password page. if (user_validate_credentials("admin", "gosecure")): flash("Please change the default password.", "notice") return redirect(url_for("user")) else: internet_status_bool = internet_status() vpn_status_bool = vpn_status() vpn_configuration_status_bool = vpn_configuration_status() #check to see if network is up. If not, redirect to network page if (internet_status_bool == False and vpn_configuration_status_bool == True): flash("Internet is not reachable.", "notice") return redirect(url_for("wifi")) #check to see if network and vpn are up. If not, redirect to initial setup page elif (internet_status_bool == False and vpn_status_bool == False): return redirect(url_for("initial_setup")) #check to see if vpn is up. If not, redirect to vpn page elif (vpn_status_bool == False): flash("VPN is not established.", "notice") return redirect(url_for("vpn_psk")) else: return redirect( request.args.get("next") or url_for("status")) else: flash("Invalid username or password. Please try again.", "error") return render_template("login.html", form=form) else: flash_form_errors(form) return render_template("login.html", form=form)
def login(): form = loginForm() if request.method == "GET": return render_template("login.html", form=form) elif request.method == "POST": if form.validate(): username = form.username.data password = form.password.data if user_validate_credentials(username, password): user = User() user.id = username flask_login.login_user(user) # check to see if default credentials are being used. If so, redirect to change password page. if user_validate_credentials("admin", "gosecure"): flash("Please change the default password.", "notice") return redirect(url_for("user")) else: internet_status_bool = internet_status() vpn_status_bool = vpn_status() vpn_configuration_status_bool = vpn_configuration_status() # check to see if network is up. If not, redirect to network page if internet_status_bool is False and vpn_configuration_status_bool is True: flash("Internet is not reachable.", "notice") return redirect(url_for("wifi")) # check to see if network and vpn are up. If not, redirect to initial setup page elif internet_status_bool is False and vpn_status_bool is False: return redirect(url_for("initial_setup")) # check to see if vpn is up. If not, redirect to vpn page elif vpn_status_bool is False: flash("VPN is not established.", "notice") return redirect(url_for("vpn_psk")) else: return redirect(request.args.get("next") or url_for("status")) else: flash("Invalid username or password. Please try again.", "error") return render_template("login.html", form=form) else: flash_form_errors(form) return render_template("login.html", form=form)