From 4e5638df36053302fd9e0d5907128a102035fb44 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Sun, 6 Oct 2024 17:13:50 +0800 Subject: [PATCH] Fixed issue #346 --- src/dashboard.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index a815452..baf8de4 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1213,12 +1213,7 @@ class DashboardConfig: if type(value) is str and len(value) == 0: return False, "Field cannot be empty!" if key == "peer_global_dns": - value = value.split(",") - for i in value: - try: - ipaddress.ip_address(i) - except ValueError as e: - return False, str(e) + return _checkDNS(value) if key == "peer_endpoint_allowed_ip": value = value.split(",") for i in value: @@ -1383,9 +1378,9 @@ def _checkIP(ip): def _checkDNS(dns): dns = dns.replace(' ', '').split(',') 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)): - return False - return True + 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, f"{i} does not appear to be an valid DNS address" + return True, "" def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]: