Make log and traffic retention configurable; limit DNS presets to Quad9

- Settings → Data retention: log file size, number of old log files,
  hourly and daily traffic history. Stored as log and stats in
  config.json, validated, and applied without a restart; lowering a
  limit deletes older log files and history after confirmation.
- Traffic history is now pruned by time instead of by bucket count.
- Server page DNS provider list offers only Quad9 and Custom.

Claude-Session: https://claude.ai/code/session_01RAnLbyQZ5ZTA7KqwXP98nw
This commit is contained in:
Daniel Redetzke
2026-10-03 17:48:33 +03:00
parent b394a6d5d9
commit 1543069089
8 changed files with 217 additions and 27 deletions
+12
View File
@@ -76,6 +76,18 @@ func (w *rotatingWriter) Write(p []byte) (int, error) {
return n, err
}
// SetLimits changes rotation size and file count at runtime. Rotated files
// beyond the new count are deleted.
func (w *rotatingWriter) SetLimits(maxMB, maxFiles int) {
w.mu.Lock()
defer w.mu.Unlock()
w.maxBytes = int64(maxMB) << 20
for i := maxFiles + 1; i <= maxLogFiles+1; i++ {
_ = os.Remove(fmt.Sprintf("%s.%d", w.path, i))
}
w.maxFiles = maxFiles
}
func (w *rotatingWriter) Close() error {
w.mu.Lock()
defer w.mu.Unlock()