Files
wild-central/internal/api/v1/handlers_ddns.go
2026-07-10 20:46:22 +00:00

31 lines
842 B
Go

package v1
import (
"net/http"
)
// DDNSStatus returns the current DDNS status (last IP, last update, last error)
func (api *API) DDNSStatus(w http.ResponseWriter, r *http.Request) {
if api.ddns == nil {
respondJSON(w, http.StatusOK, map[string]any{
"enabled": false,
"message": "DDNS not configured",
})
return
}
respondJSON(w, http.StatusOK, api.ddns.GetStatus())
}
// DDNSTrigger forces an immediate DDNS check. The runner reads fresh params
// (token, records) via its callback, so updated tokens take effect immediately.
func (api *API) DDNSTrigger(w http.ResponseWriter, r *http.Request) {
if api.ddns == nil {
respondError(w, http.StatusServiceUnavailable, "DDNS not configured")
return
}
api.reloadDDNSIfEnabled()
respondJSON(w, http.StatusOK, map[string]string{
"message": "DDNS update triggered",
})
}