Skip to content

Commit

Permalink
updated control mappings
Browse files Browse the repository at this point in the history
updated the control mapping for better usage und easier overview
  • Loading branch information
agmes4 committed Sep 9, 2023
1 parent 6f5dca5 commit c50ea6c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions sipa/blueprints/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -46,4 +47,7 @@ def checks_ip_address():

@bp_control.route('/delete', methods=['DELETE'])
def delete():
return ""
"""
returns emtpy string for simple deleting things
"""
return ""

0 comments on commit c50ea6c

Please sign in to comment.