diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index b03a98c..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/internal/locales/de.json b/internal/locales/de.json index abbec26..b74f74f 100644 --- a/internal/locales/de.json +++ b/internal/locales/de.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "Neu in letzter Stunde", "dashboard.table.banned_ips": "Gesperrte IPs (Entsperren)", "dashboard.no_jails": "Keine Jails gefunden.", - "dashboard.last_bans": "Letzte 5 Sperrvorgänge", "dashboard.table.time": "Zeit", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Logzeile", - "dashboard.no_recent_bans": "Keine aktuellen Sperrvorgänge gefunden.", "dashboard.no_banned_ips": "Keine gesperrten IPs", "dashboard.unban": "Entsperren", "logs.overview.title": "Interne Log-Übersicht", diff --git a/internal/locales/de_ch.json b/internal/locales/de_ch.json index 07c0b36..fb4df41 100644 --- a/internal/locales/de_ch.json +++ b/internal/locales/de_ch.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "Neu in dr letschte Stund", "dashboard.table.banned_ips": "G'sperrti IPs (Entsperre)", "dashboard.no_jails": "Kei Jails gfunde.", - "dashboard.last_bans": "Letschti 5 Sperrvorgäng", "dashboard.table.time": "Zyt", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Log-Zile", - "dashboard.no_recent_bans": "Kei aktuelli Sperrvorgäng gfunde.", "dashboard.no_banned_ips": "Kei g'sperrti IPs", "dashboard.unban": "Entsperre", "logs.overview.title": "Interni Log-Übersicht", diff --git a/internal/locales/en.json b/internal/locales/en.json index 30eaa27..b51712b 100644 --- a/internal/locales/en.json +++ b/internal/locales/en.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "New Last Hour", "dashboard.table.banned_ips": "Banned IPs (Unban)", "dashboard.no_jails": "No jails found.", - "dashboard.last_bans": "Last 5 Ban Events", "dashboard.table.time": "Time", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Log Line", - "dashboard.no_recent_bans": "No recent bans found.", "dashboard.no_banned_ips": "No banned IPs", "dashboard.unban": "Unban", "logs.overview.title": "Internal Log Overview", diff --git a/internal/locales/es.json b/internal/locales/es.json index 3814692..5cf2397 100644 --- a/internal/locales/es.json +++ b/internal/locales/es.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "Nuevas en la última hora", "dashboard.table.banned_ips": "IPs bloqueadas (Desbloquear)", "dashboard.no_jails": "No se encontraron jails.", - "dashboard.last_bans": "Últimos 5 eventos de bloqueo", "dashboard.table.time": "Hora", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Línea de log", - "dashboard.no_recent_bans": "No se encontraron bloqueos recientes.", "dashboard.no_banned_ips": "No hay IP bloqueadas", "dashboard.unban": "Desbloquear", "logs.overview.title": "Resumen interno de registros", diff --git a/internal/locales/fr.json b/internal/locales/fr.json index a480b93..77a599c 100644 --- a/internal/locales/fr.json +++ b/internal/locales/fr.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "Nouveaux dans la dernière heure", "dashboard.table.banned_ips": "IPs bloquées (Débloquer)", "dashboard.no_jails": "Aucun jail trouvé.", - "dashboard.last_bans": "5 derniers événements de blocage", "dashboard.table.time": "Heure", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Ligne de log", - "dashboard.no_recent_bans": "Aucun blocage récent trouvé.", "dashboard.no_banned_ips": "Aucune IP bloquée", "dashboard.unban": "Débloquer", "logs.overview.title": "Vue d'ensemble interne des journaux", diff --git a/internal/locales/it.json b/internal/locales/it.json index ad7e7f2..b3bf6a0 100644 --- a/internal/locales/it.json +++ b/internal/locales/it.json @@ -27,12 +27,10 @@ "dashboard.table.new_last_hour": "Nuove nell'ultima ora", "dashboard.table.banned_ips": "IP bloccate (Sblocca)", "dashboard.no_jails": "Nessun jail trovato.", - "dashboard.last_bans": "Ultimi 5 eventi di blocco", "dashboard.table.time": "Ora", "dashboard.table.jail": "Jail", "dashboard.table.ip": "IP", "dashboard.table.log_line": "Riga di log", - "dashboard.no_recent_bans": "Nessun blocco recente trovato.", "dashboard.no_banned_ips": "Nessuna IP bloccata", "dashboard.unban": "Sblocca", "logs.overview.title": "Panoramica interna dei log", diff --git a/pkg/web/handlers.go b/pkg/web/handlers.go index 97517f9..5c09d5c 100644 --- a/pkg/web/handlers.go +++ b/pkg/web/handlers.go @@ -43,8 +43,7 @@ import ( // SummaryResponse is what we return from /api/summary type SummaryResponse struct { - Jails []fail2ban.JailInfo `json:"jails"` - LastBans []fail2ban.BanEvent `json:"lastBans"` + Jails []fail2ban.JailInfo `json:"jails"` } func resolveConnector(c *gin.Context) (fail2ban.Connector, error) { @@ -89,7 +88,6 @@ func resolveServerForNotification(serverID, hostname string) (config.Fail2banSer // SummaryHandler returns a JSON summary of all jails, including // number of banned IPs, how many are new in the last hour, etc. -// and the last 5 overall ban events from the log. func SummaryHandler(c *gin.Context) { conn, err := resolveConnector(c) if err != nil { @@ -103,15 +101,8 @@ func SummaryHandler(c *gin.Context) { return } - lastBans, err := conn.FetchBanEvents(c.Request.Context(), 5) - if err != nil { - log.Printf("warning: failed to fetch ban events for summary: %v", err) - lastBans = []fail2ban.BanEvent{} - } - resp := SummaryResponse{ - Jails: jailInfos, - LastBans: lastBans, + Jails: jailInfos, } c.JSON(http.StatusOK, resp) } @@ -504,16 +495,6 @@ func shouldAlertForCountry(country string, alertCountries []string) bool { return false } -func sortByTimeDesc(events []fail2ban.BanEvent) { - for i := 0; i < len(events); i++ { - for j := i + 1; j < len(events); j++ { - if events[j].Time.After(events[i].Time) { - events[i], events[j] = events[j], events[i] - } - } - } -} - // IndexHandler serves the HTML page func IndexHandler(c *gin.Context) { c.HTML(http.StatusOK, "index.html", gin.H{ diff --git a/pkg/web/templates/index.html b/pkg/web/templates/index.html index ff8b87a..f6519e0 100644 --- a/pkg/web/templates/index.html +++ b/pkg/web/templates/index.html @@ -1190,7 +1190,14 @@ if (isNaN(date.getTime())) { return value; } - return date.toLocaleString(); + // Format as "2025.11.12, 21:21:52" + var year = date.getFullYear(); + var month = String(date.getMonth() + 1).padStart(2, '0'); + var day = String(date.getDate()).padStart(2, '0'); + var hours = String(date.getHours()).padStart(2, '0'); + var minutes = String(date.getMinutes()).padStart(2, '0'); + var seconds = String(date.getSeconds()).padStart(2, '0'); + return year + '.' + month + '.' + day + ', ' + hours + ':' + minutes + ':' + seconds; } function totalStoredBans() { @@ -1316,38 +1323,6 @@ html += ''; } - if (summary.lastBans) { - html += '
No recent bans found.
'; - } else { - html += '' - + '| Time | ' - + 'Jail | ' - + 'IP | ' - + 'Details | ' - + '
|---|---|---|---|
| ' + escapeHtml(event.Time || '') + ' | ' - + '' + escapeHtml(event.Jail || '') + ' | ' - + '' + escapeHtml(event.IP || '') + ' | ' - + '' + escapeHtml(event.LogLine || '') + ' | ' - + '