Support passwordless Pi-hole authentication and UI settings
All checks were successful
Test and publish Homegate / publish (push) Successful in 12m49s
Test and publish Homegate / checks (push) Successful in 29s

This commit is contained in:
2026-10-14 18:12:10 +03:00
parent a83d897b70
commit b305cc1ba8
13 changed files with 130 additions and 33 deletions

View File

@@ -136,9 +136,13 @@ class Panel:
if self.config_data()[1] != revision:
raise UIError("Настройки уже изменились. Обновите страницу.", 409)
values = h.read_json(self.connections_file, {})
allowed = {"npm_url", "npm_identity", "npm_password", "pihole_url", "pihole_password", "ssh_public_url", "api_ca_pem"}
allowed = {"npm_url", "npm_identity", "npm_password", "pihole_url", "pihole_password", "ssh_public_url", "api_ca_pem", "clear_pihole_password"}
h.require(not set(connections) - allowed, "Unknown connection field")
clear_pihole_password = connections.get("clear_pihole_password", False)
h.require(isinstance(clear_pihole_password, bool), "clear_pihole_password must be boolean")
for key, value in connections.items():
if key == "clear_pihole_password":
continue
h.require(isinstance(value, str), f"{key} must be text")
if key.endswith("_password") and not value and values.get(key):
continue
@@ -151,6 +155,8 @@ class Panel:
client = h.API(values.get(key, ""), key.removesuffix("_url").upper())
client.close()
values.setdefault("pihole_password", "")
if clear_pihole_password:
values["pihole_password"] = ""
if values.get("ssh_public_url"):
url = urlsplit(values["ssh_public_url"])
h.require(url.scheme in ("http", "https") and url.hostname and not url.username and not url.fragment,