From c50ea6c75c2141846fb57c079bad4bb3f10ff047 Mon Sep 17 00:00:00 2001 From: agames4 Date: Sat, 9 Sep 2023 20:56:42 +0200 Subject: [PATCH] updated control mappings updated the control mapping for better usage und easier overview --- sipa/blueprints/control.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sipa/blueprints/control.py b/sipa/blueprints/control.py index 72d54fde..6f9437a6 100644 --- a/sipa/blueprints/control.py +++ b/sipa/blueprints/control.py @@ -12,31 +12,32 @@ from markupsafe import Markup bp_control = Blueprint('control', __name__, url_prefix='/control') -@bp_control.route("/port", methods=['GET', 'POST']) +@bp_control.route("/port", methods=['POST']) def check_port(): """ returns json with all the port forwardings """ - if not request.form.get("port"): - return 'port nicht in Textfeld' - if not request.form["port"].isnumeric(): - return gettext('der Port muss eine Nummer sein') - if int(request.form["port"]) < 1: - return gettext('der Port muss größer als 0 sein') - if int(request.form["port"]) > 65535: - return gettext('der Port muss kleiner als 65536 sein') + for i in request.form: + if not request.form.get(i): + return 'port nicht in Textfeld' + if not request.form[i].isnumeric(): + return gettext('der Port muss eine Nummer sein') + if int(request.form[i]) < 1: + return gettext('der Port muss größer als 0 sein') + if int(request.form[i]) > 65535: + return gettext('der Port muss kleiner als 65536 sein') return "" -@bp_control.route("/ip", methods=['GET', 'POST']) +@bp_control.route("/ip", methods=['POST']) def checks_ip_address(): """ checks rather the given ip address is valid """ - if not request.form.get("source_ip"): + if not request.form.get("ip_address"): return "das Feld muss eine ip addresse enthalten" try: - ip = ipaddress.ip_address(request.form.get("source_ip")) + ip = ipaddress.ip_address(request.form.get("ip_address")) except ValueError: return "die IP scheint keine valide IP Adresse zu sein" network = ipaddress.ip_network("192.168.10.0/24") @@ -46,4 +47,7 @@ def checks_ip_address(): @bp_control.route('/delete', methods=['DELETE']) def delete(): - return "" \ No newline at end of file + """ + returns emtpy string for simple deleting things + """ + return ""