feat(dyndns): add get_ddns_status() for os-ddclient enabled/running state
CI / test (3.10) (push) Failing after 8s
CI / test (3.11) (push) Failing after 7s
CI / test (3.12) (push) Failing after 7s
CI / test (3.9) (push) Failing after 7s

Verified against a live OPNsense 24.7 instance: the service id is
"ddclient" but the REST module is "dyndns" (/api/ddclient/* all 404).
Scoped to enabled/running only -- no ddclient/dyndns account was
configured on the test device to verify a per-account "registered IP"
shape against, so that comparison is deliberately left out rather than
guessed.
This commit is contained in:
Christian Manivong
2026-07-15 13:52:20 +02:00
parent 26470676ce
commit c8caa14176
2 changed files with 87 additions and 0 deletions
+27
View File
@@ -1091,6 +1091,33 @@ class OPNsenseDriver(FirewallDriver):
})
return result
def get_ddns_status(self) -> dict[str, Any] | None:
"""Return Dynamic DNS (os-ddclient) enabled/running state.
Calls ``GET /api/dyndns/service/status`` and
``GET /api/dyndns/settings/get`` -- note the API module is
"dyndns", not "ddclient" (the service id reported by
get_services() is "ddclient", but its REST controller lives under
a different, historical module name).
Returns ``{"enabled": bool, "running": bool}``, or ``None`` if the
plugin isn't installed/reachable. Scoped to enabled/running only:
no per-account "registered IP" comparison, since that would need a
configured account to verify the response shape against.
"""
try:
status = self._get("/api/dyndns/service/status")
settings = self._get("/api/dyndns/settings/get")
except Exception as exc:
logger.warning("get_ddns_status() failed: %s", exc)
return None
general = settings.get("ddclient", {}).get("general", {})
return {
"enabled": general.get("enabled") == "1",
"running": status.get("status") == "running",
}
def get_dhcp_leases(self) -> list[dict[str, Any]]:
"""Return active DHCP leases from OPNsense.