Skip to content

Commit

Permalink
added Mac address validation
Browse files Browse the repository at this point in the history
added route for the Mac validation
  • Loading branch information
agmes4 committed Sep 8, 2023
1 parent e0d0490 commit 4e79364
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sipa/blueprints/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict
import logging
from datetime import datetime
import ipaddress

from babel.numbers import format_currency
from flask import Blueprint, render_template, url_for, redirect, flash, abort, request, current_app
Expand Down Expand Up @@ -31,4 +32,14 @@ def checks_ip_address():
"""
checks rather the given ip address is valid
"""
pass

if not request.form.get("source_ip"):
return "das Feld muss eine ip addresse enthalten"
try:
ip = ipaddress.ip_address(request.form.get("source_ip"))
except ValueError:
return "die IP scheint keine valide IP Adresse zu sein"
network = ipaddress.ip_network("192.168.10.0/24")
if ip not in network:
return "die angegebene IP gehört nicht zu deinem Subnetz"
return ""

0 comments on commit 4e79364

Please sign in to comment.