feat(keenetic): edit KeenDNS address from dashboard

Add PATCH endpoint and inline card editor to update web_url and host,
with URL validation and automatic refresh after save.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Андрей Бобырев
2026-05-22 01:02:01 +03:00
parent 746ecfc343
commit 8f8e9a3234
4 changed files with 228 additions and 0 deletions

View File

@@ -27,6 +27,23 @@ def normalize_web_url(url: str) -> str:
return url.rstrip("/")
def parse_keenetic_web_url(url: str) -> tuple[str, str]:
"""Validate KeenDNS/web URL; return (web_url, host) with port in host."""
raw = (url or "").strip()
if not raw:
raise ValueError("Укажите адрес KeenDNS")
if "://" in raw:
normalized = raw.rstrip("/")
else:
normalized = f"https://{raw}".rstrip("/")
parsed = urlparse(normalized)
if not parsed.scheme or parsed.scheme not in ("http", "https"):
raise ValueError("Адрес должен начинаться с http:// или https://")
if not parsed.netloc or not parsed.hostname:
raise ValueError("Некорректный формат адреса")
return normalized, parsed.netloc
def is_public_ip_host(host: str) -> bool:
"""True when host is a bare IPv4 (optional :port), not KeenDNS."""
if not host: