dhcp: track pending config changes with hash, update UI button

This commit is contained in:
2026-06-28 16:26:32 +00:00
parent baa441fa13
commit 348bbfbca6
3 changed files with 59 additions and 16 deletions
+13
View File
@@ -5,6 +5,8 @@ state instead of invoking subprocesses on every request.
"""
import contextlib
import hashlib
import json
import logging
import os
from copy import deepcopy
@@ -588,12 +590,23 @@ def _collect_dnsmasq() -> dict[str, Any]:
# Check config file on disk
conf_exists = Path(DNSMASQ_CONF).is_file()
# Check if JSON config has changed since last apply
_APPLY_HASH_KEY = "_last_applied_hash"
pending_changes = True
if _APPLY_HASH_KEY in cfg:
clean = {k: v for k, v in cfg.items() if k != _APPLY_HASH_KEY}
current_hash = hashlib.sha256(
json.dumps(clean, sort_keys=True).encode()
).hexdigest()
pending_changes = cfg[_APPLY_HASH_KEY] != current_hash
return {
"config": cfg,
"status": {
"service_active": service_active,
"config_file_exists": conf_exists,
"active_leases": len(leases),
"pending_changes": pending_changes,
},
"leases": leases,
"timestamp": _now_iso(),