Add serverID to all events to sort per fail2ban instance, update language

This commit is contained in:
2025-11-17 20:24:46 +01:00
parent b1bdb66516
commit 2456162b75
10 changed files with 163 additions and 1330 deletions

View File

@@ -248,6 +248,7 @@ func BanInsightsHandler(c *gin.Context) {
since = parsed
}
}
serverID := c.Query("serverId")
minCount := 3
if minCountStr := c.DefaultQuery("minCount", "3"); minCountStr != "" {
@@ -265,19 +266,19 @@ func BanInsightsHandler(c *gin.Context) {
ctx := c.Request.Context()
countriesMap, err := storage.CountBanEventsByCountry(ctx, since)
countriesMap, err := storage.CountBanEventsByCountry(ctx, since, serverID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
recurring, err := storage.ListRecurringIPStats(ctx, since, minCount, limit)
recurring, err := storage.ListRecurringIPStats(ctx, since, minCount, limit, serverID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
totalOverall, err := storage.CountBanEvents(ctx, time.Time{})
totalOverall, err := storage.CountBanEvents(ctx, time.Time{}, serverID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
@@ -285,13 +286,13 @@ func BanInsightsHandler(c *gin.Context) {
now := time.Now().UTC()
totalToday, err := storage.CountBanEvents(ctx, now.Add(-24*time.Hour))
totalToday, err := storage.CountBanEvents(ctx, now.Add(-24*time.Hour), serverID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
totalWeek, err := storage.CountBanEvents(ctx, now.Add(-7*24*time.Hour))
totalWeek, err := storage.CountBanEvents(ctx, now.Add(-7*24*time.Hour), serverID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return