mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Implementing WebSocked Support for immediately ban-messages
This commit is contained in:
@@ -46,6 +46,14 @@ import (
|
||||
"github.com/swissmakers/fail2ban-ui/internal/storage"
|
||||
)
|
||||
|
||||
// wsHub is the global WebSocket hub instance
|
||||
var wsHub *Hub
|
||||
|
||||
// SetWebSocketHub sets the global WebSocket hub instance
|
||||
func SetWebSocketHub(hub *Hub) {
|
||||
wsHub = hub
|
||||
}
|
||||
|
||||
// SummaryResponse is what we return from /api/summary
|
||||
type SummaryResponse struct {
|
||||
Jails []fail2ban.JailInfo `json:"jails"`
|
||||
@@ -603,6 +611,11 @@ func HandleBanNotification(ctx context.Context, server config.Fail2banServer, ip
|
||||
log.Printf("⚠️ Failed to record ban event: %v", err)
|
||||
}
|
||||
|
||||
// Broadcast ban event to WebSocket clients
|
||||
if wsHub != nil {
|
||||
wsHub.BroadcastBanEvent(event)
|
||||
}
|
||||
|
||||
evaluateAdvancedActions(ctx, settings, server, ip)
|
||||
|
||||
// Check if country is in alert list
|
||||
|
||||
Reference in New Issue
Block a user