mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-04 10:24:41 +02:00
Use better python method for validating IP address and subnet
This commit is contained in:
parent
6466759f30
commit
0e04871cbe
@ -96,22 +96,22 @@ def build_app(path):
|
||||
data['uid'] = str(uuid.uuid4())
|
||||
valid = True
|
||||
try:
|
||||
ipaddress.ip_address(data['bind4'])
|
||||
ipaddress.IPv4Address(data['bind4'])
|
||||
except:
|
||||
flask.flash('Configured IPv4 address is invalid', 'error')
|
||||
valid = False
|
||||
try:
|
||||
ipaddress.ip_address(data['bind6'])
|
||||
ipaddress.IPv6Address(data['bind6'])
|
||||
except:
|
||||
flask.flash('Configured IPv6 address is invalid', 'error')
|
||||
valid = False
|
||||
try:
|
||||
ipaddress.ip_network(data['subnet'])
|
||||
ipaddress.IPv4Network(data['subnet'])
|
||||
except:
|
||||
flask.flash('Configured subnet(IPv4) is invalid', 'error')
|
||||
valid = False
|
||||
try:
|
||||
ipaddress.ip_network(data['subnet6'])
|
||||
ipaddress.IPv6Network(data['subnet6'])
|
||||
except:
|
||||
flask.flash('Configured subnet(IPv6) is invalid', 'error')
|
||||
valid = False
|
||||
|
Loading…
Reference in New Issue
Block a user