geoip and config editor online
This commit is contained in:
@@ -3,6 +3,7 @@ package handlers
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"crowdsec-dashy/internal/crowdsec"
|
||||
@@ -33,7 +34,19 @@ func (h *DashboardHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if h.deps.CLIAvailable {
|
||||
decisions, _ = h.deps.CLI.ListDecisions(ctx, crowdsec.DecisionFilter{Limit: 10})
|
||||
}
|
||||
alerts, _ := h.deps.LAPI.ListAlerts(ctx, crowdsec.AlertFilter{Limit: 10})
|
||||
// Fetch extra so filtering "update :" scenarios still yields 10 real threats.
|
||||
rawAlerts, _ := h.deps.LAPI.ListAlerts(ctx, crowdsec.AlertFilter{Limit: 50})
|
||||
var alerts []crowdsec.Alert
|
||||
for _, a := range rawAlerts {
|
||||
s := a.Scenario
|
||||
if strings.HasPrefix(s, "update :") || strings.HasPrefix(s, "update:") {
|
||||
continue
|
||||
}
|
||||
alerts = append(alerts, a)
|
||||
if len(alerts) == 10 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
h.deps.Renderer.Render(w, "dashboard", DashboardData{
|
||||
PageData: NewPageData(r, "Dashboard", h.deps.CLIAvailable, h.deps.PollInterval),
|
||||
|
||||
Reference in New Issue
Block a user