31 lines
842 B
Go
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",
|
|
})
|
|
}
|