v0.1.2
Go quality gates / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-12-01 00:16:15 +01:00
1 parent de13d851a8
commit a28362b82c
34 files changed
+1541 -341

No files matched your search

+12 -3
View File
@@ -14,6 +14,7 @@ import (
"git.linuxiarz.pl/gru/EasyDNS-Web/internal/config"
"git.linuxiarz.pl/gru/EasyDNS-Web/internal/multiserver"
"git.linuxiarz.pl/gru/EasyDNS-Web/internal/telemetry"
)
var Version = "dev"
@@ -126,8 +127,12 @@ func (s *Server) dispatch(w http.ResponseWriter, r *http.Request) {
s.auth.setCookie(w, "", -1)
clearNodeCookie(w, s.cfg.CookieSecure)
http.Redirect(w, r, "/login", http.StatusSeeOther)
case r.URL.Path == "/servers" && r.Method == "GET" && s.nodes.Enabled():
s.serversOverview(w, r)
case r.URL.Path == "/servers" && r.Method == "GET":
if !s.nodes.Enabled() {
redirect(w, r, "/configuration?notice=server-inventory-disabled#multi-server-preference")
} else {
s.serversOverview(w, r)
}
case r.URL.Path == "/servers/new" && r.Method == "GET" && s.nodes.Enabled():
s.serverNewForm(w, r)
case r.URL.Path == "/servers" && r.Method == "POST" && s.nodes.Enabled():
@@ -269,6 +274,8 @@ func notice(n string) (string, string) {
return "Multi-server management is enabled. Your local EasyDNS remains the default server.", "ok"
case "servers-disabled":
return "Multi-server management is disabled. Saved remote connections are retained but inactive.", "ok"
case "server-inventory-disabled":
return "Server inventory requires Multi-server management. Enable it in panel settings or in your deployment configuration.", "warn"
case "session-ended":
return "Signed out.", "ok"
default:
@@ -289,9 +296,11 @@ func (s *Server) telemetryJSON(w http.ResponseWriter, r *http.Request) {
return
}
smp, errText, last := s.telemetry.Snapshot()
window := telemetry.ParseWindow(r.URL.Query().Get("range"), r.URL.Query().Get("step"), time.Now().UTC())
smp = telemetry.WindowSamples(smp, window)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("Cache-Control", "no-store")
_ = json.NewEncoder(w).Encode(map[string]any{"samples": smp, "error": errText, "lastPoll": last, "intervalSeconds": 15})
_ = json.NewEncoder(w).Encode(map[string]any{"samples": smp, "error": errText, "lastPoll": last, "intervalSeconds": int(telemetry.PollInterval / time.Second), "range": window.Range, "step": window.Step, "stepSeconds": window.StepSeconds, "from": window.From, "to": window.To, "retentionHours": 24})
}
func (s *Server) loginPage(w http.ResponseWriter, r *http.Request) {
if _, ok := s.auth.parseSession(r); ok {