mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 07:10:09 +01:00
Fixed issue #346
This commit is contained in:
parent
71349f35e4
commit
4e5638df36
@ -1213,12 +1213,7 @@ class DashboardConfig:
|
|||||||
if type(value) is str and len(value) == 0:
|
if type(value) is str and len(value) == 0:
|
||||||
return False, "Field cannot be empty!"
|
return False, "Field cannot be empty!"
|
||||||
if key == "peer_global_dns":
|
if key == "peer_global_dns":
|
||||||
value = value.split(",")
|
return _checkDNS(value)
|
||||||
for i in value:
|
|
||||||
try:
|
|
||||||
ipaddress.ip_address(i)
|
|
||||||
except ValueError as e:
|
|
||||||
return False, str(e)
|
|
||||||
if key == "peer_endpoint_allowed_ip":
|
if key == "peer_endpoint_allowed_ip":
|
||||||
value = value.split(",")
|
value = value.split(",")
|
||||||
for i in value:
|
for i in value:
|
||||||
@ -1383,9 +1378,9 @@ def _checkIP(ip):
|
|||||||
def _checkDNS(dns):
|
def _checkDNS(dns):
|
||||||
dns = dns.replace(' ', '').split(',')
|
dns = dns.replace(' ', '').split(',')
|
||||||
for i in dns:
|
for i in dns:
|
||||||
if not (_checkIP(i) or regex_match(r"(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]", i)):
|
if not _checkIP(i) and not regex_match(r"(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z]{0,61}[a-z]", i):
|
||||||
return False
|
return False, f"{i} does not appear to be an valid DNS address"
|
||||||
return True
|
return True, ""
|
||||||
|
|
||||||
|
|
||||||
def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]:
|
def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]:
|
||||||
|
Loading…
Reference in New Issue
Block a user