feat(dns+ntp): DNS-Cache-Flush + NTP-Force-Sync — operative Aktionen (1.1.94)
Backend: POST /dns/flush-cache (unbound-control flush_zone .)
POST /ntp/force-sync (chronyc makestep)
Beide werden im Audit-Log festgehalten.
UI: Schaltflächen in DNS-Settings und NTP-Settings neben Save,
mit Tooltip-Beschreibung + i18n (de+en).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"os/exec"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -54,6 +55,7 @@ func (h *DNSHandler) Register(rg *gin.RouterGroup) {
|
||||
|
||||
g.GET("/settings", h.GetSettings)
|
||||
g.PUT("/settings", h.UpdateSettings)
|
||||
g.POST("/flush-cache", h.FlushCache)
|
||||
}
|
||||
|
||||
// ── Zones ──────────────────────────────────────────────────────
|
||||
@@ -287,6 +289,20 @@ func (h *DNSHandler) UpdateSettings(c *gin.Context) {
|
||||
h.reload(c.Request.Context(), "settings.update")
|
||||
}
|
||||
|
||||
// FlushCache runs `unbound-control flush_zone .` which discards all
|
||||
// cached RRs from the resolver. Useful after DNS propagation or when
|
||||
// stale records need to be evicted immediately.
|
||||
func (h *DNSHandler) FlushCache(c *gin.Context) {
|
||||
out, err := exec.CommandContext(c.Request.Context(), "unbound-control", "flush_zone", ".").CombinedOutput()
|
||||
if err != nil {
|
||||
slog.Error("dns flush-cache failed", "err", err, "out", string(out))
|
||||
response.Internal(c, err)
|
||||
return
|
||||
}
|
||||
_ = h.Audit.Log(c.Request.Context(), actorOf(c), "dns.flush-cache", "unbound", nil, h.NodeID)
|
||||
response.OK(c, gin.H{"message": "cache flushed", "output": string(out)})
|
||||
}
|
||||
|
||||
// ── Validation ─────────────────────────────────────────────────
|
||||
|
||||
func validateZone(z *models.DNSZone) error {
|
||||
|
||||
Reference in New Issue
Block a user