feat(dyndns): add get_ddns_status() for os-ddclient enabled/running state
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:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user