mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Add serverID to all events to sort per fail2ban instance, update language
This commit is contained in:
@@ -537,8 +537,8 @@ WHERE 1=1`
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
// CountBanEvents returns total number of ban events optionally filtered by time.
|
||||
func CountBanEvents(ctx context.Context, since time.Time) (int64, error) {
|
||||
// CountBanEvents returns total number of ban events optionally filtered by time and server.
|
||||
func CountBanEvents(ctx context.Context, since time.Time, serverID string) (int64, error) {
|
||||
if db == nil {
|
||||
return 0, errors.New("storage not initialised")
|
||||
}
|
||||
@@ -549,6 +549,11 @@ FROM ban_events
|
||||
WHERE 1=1`
|
||||
args := []any{}
|
||||
|
||||
if serverID != "" {
|
||||
query += " AND server_id = ?"
|
||||
args = append(args, serverID)
|
||||
}
|
||||
|
||||
if !since.IsZero() {
|
||||
query += " AND occurred_at >= ?"
|
||||
args = append(args, since.UTC())
|
||||
@@ -561,8 +566,8 @@ WHERE 1=1`
|
||||
return total, nil
|
||||
}
|
||||
|
||||
// CountBanEventsByCountry returns aggregation per country code.
|
||||
func CountBanEventsByCountry(ctx context.Context, since time.Time) (map[string]int64, error) {
|
||||
// CountBanEventsByCountry returns aggregation per country code, optionally filtered by server.
|
||||
func CountBanEventsByCountry(ctx context.Context, since time.Time, serverID string) (map[string]int64, error) {
|
||||
if db == nil {
|
||||
return nil, errors.New("storage not initialised")
|
||||
}
|
||||
@@ -573,6 +578,11 @@ FROM ban_events
|
||||
WHERE 1=1`
|
||||
args := []any{}
|
||||
|
||||
if serverID != "" {
|
||||
query += " AND server_id = ?"
|
||||
args = append(args, serverID)
|
||||
}
|
||||
|
||||
if !since.IsZero() {
|
||||
query += " AND occurred_at >= ?"
|
||||
args = append(args, since.UTC())
|
||||
@@ -599,8 +609,8 @@ WHERE 1=1`
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
// ListRecurringIPStats returns IPs that have been banned at least minCount times.
|
||||
func ListRecurringIPStats(ctx context.Context, since time.Time, minCount, limit int) ([]RecurringIPStat, error) {
|
||||
// ListRecurringIPStats returns IPs that have been banned at least minCount times, optionally filtered by server.
|
||||
func ListRecurringIPStats(ctx context.Context, since time.Time, minCount, limit int, serverID string) ([]RecurringIPStat, error) {
|
||||
if db == nil {
|
||||
return nil, errors.New("storage not initialised")
|
||||
}
|
||||
@@ -618,6 +628,11 @@ FROM ban_events
|
||||
WHERE ip != ''`
|
||||
args := []any{}
|
||||
|
||||
if serverID != "" {
|
||||
query += " AND server_id = ?"
|
||||
args = append(args, serverID)
|
||||
}
|
||||
|
||||
if !since.IsZero() {
|
||||
query += " AND occurred_at >= ?"
|
||||
args = append(args, since.UTC())
|
||||
|
||||
Reference in New Issue
Block a user