mirror of https://git.48k.eu/ogcp
views: validate ip in client creation and update
Check the provided IP is valid before trying to send the payload to the server.master
parent
1d8c752901
commit
b3c25a827b
|
@ -29,6 +29,7 @@ from ogcp.og_server import OGServer, servers
|
|||
from flask_babel import lazy_gettext as _l
|
||||
from flask_babel import gettext, _
|
||||
from ogcp import app, ogcp_cfg_path
|
||||
import ipaddress
|
||||
import requests
|
||||
import datetime
|
||||
import hashlib
|
||||
|
@ -1234,6 +1235,13 @@ def action_client_info():
|
|||
def action_client_update():
|
||||
form = ClientDetailsForm(request.form)
|
||||
if request.method == 'POST':
|
||||
|
||||
try:
|
||||
ipaddress.ip_address(form.ip.data)
|
||||
except ValueError as e:
|
||||
flash(_('Invalid IP address'), category='error')
|
||||
return redirect(url_for("scopes"))
|
||||
|
||||
payload = {"ip": form.ip.data,
|
||||
"serial_number": form.serial_number.data,
|
||||
"netdriver": "generic",
|
||||
|
@ -1480,6 +1488,12 @@ def action_client_add():
|
|||
flash(form.errors, category='error')
|
||||
return redirect(url_for('servers'))
|
||||
|
||||
try:
|
||||
ipaddress.ip_address(form.ip.data)
|
||||
except ValueError as e:
|
||||
flash(_('Invalid IP address'), category='error')
|
||||
return redirect(url_for("scopes"))
|
||||
|
||||
payload = {"boot": form.boot.data,
|
||||
"ip": form.ip.data,
|
||||
"livedir": form.livedir.data,
|
||||
|
|
Loading…
Reference in New Issue