feat: 1.4.6 unban from the UI, operator allows, day-counter fallback for long windows
Release / Publish tags (push) Successful in 16s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Successful in 1m47s
Release / Build image (amd64) (push) Successful in 21s
Release / Build image (arm64) (push) Successful in 23s
CI / Format and vet (push) Successful in 27s
CI / Tests (Linux, race detector) (push) Successful in 1m20s
CI / Dependency audit (push) Successful in 31s
CI / Docker image (build and smoke test) (push) Skipped
Release / Gitea release (push) Successful in 5s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 01:53:24 -03:00
1 parent 1ef5a0ce9f
commit da333d70f1
25 files changed
+841 -33

No files matched your search

+37 -4
View File
@@ -14,6 +14,32 @@ type RosterRow struct {
Level core.Level
Jails []string
Last int64
Est Tally24 // 24 h estimate from the per-day counters (the registry may not cover the whole window)
}
// dayEstimate estimates the SSH and web malicious events of the last 24 h from
// the per-day counters: today plus the share of yesterday still inside the window.
func dayEstimate(r *IPRec, nowU int64) Tally24 {
if len(r.DayCats) == 0 {
return Tally24{}
}
today := nowU / 86400
frac := 1 - float64(nowU%86400)/86400
var t Tally24
for k := int64(0); k <= 1; k++ {
i := int(r.DayBase - (today - k))
if i < 0 || i >= len(r.DayCats) {
continue
}
w := 1.0
if k == 1 {
w = frac
}
c := r.DayCats[i]
t.SSH += int(float64(c[core.SSHFail.Index()])*w + 0.999)
t.Web += int(float64(c[core.Scanner.Index()]+c[core.Exploit.Index()]+c[core.BruteForce.Index()])*w + 0.999)
}
return t
}
// Tally24 counts the malicious events of one address in a window.
@@ -31,7 +57,7 @@ func (s *Store) AttackRoster(from int64) []RosterRow {
}
strong := r.Strong || attackKinds(r.Counts) >= 2
out = append(out, RosterRow{IP: ip, Score: round1(r.Score), Level: core.LevelOf(r.Score, strong, r.adminAt(nowU)),
Jails: append([]string(nil), r.Jails...), Last: r.Last})
Jails: append([]string(nil), r.Jails...), Last: r.Last, Est: dayEstimate(r, nowU)})
}
return out
}
@@ -72,7 +98,7 @@ func (s *Store) AttackTallies(from int64) map[string]Tally24 {
return nil
}
m := map[string]*Tally24{}
s.elog.Scan(evlog.Filter{From: from, Cats: tallyCats}, 256<<20, false, func(r evlog.Rec, _ []byte) bool {
s.elog.Scan(evlog.Filter{From: from, Cats: tallyCats}, 4<<30, false, func(r evlog.Rec, _ []byte) bool {
tallyAdd(m, r)
return true
})
@@ -85,11 +111,17 @@ func (s *Store) AttackTallies(from int64) map[string]Tally24 {
// AttackTally is AttackTallies for one address.
func (s *Store) AttackTally(ip string, from int64) Tally24 {
var est Tally24
s.mu.RLock()
if r := s.ips[KeyOf(ip)]; r != nil {
est = dayEstimate(r, s.now().Unix())
}
s.mu.RUnlock()
if s.elog == nil {
return Tally24{}
return est
}
m := map[string]*Tally24{}
s.elog.Scan(evlog.Filter{From: from, IP: ip, Cats: tallyCats}, 64<<20, false, func(r evlog.Rec, _ []byte) bool {
s.elog.Scan(evlog.Filter{From: from, IP: ip, Cats: tallyCats}, 1<<30, false, func(r evlog.Rec, _ []byte) bool {
tallyAdd(m, r)
return true
})
@@ -98,5 +130,6 @@ func (s *Store) AttackTally(ip string, from int64) Tally24 {
t.SSH += v.SSH
t.Web += v.Web
}
t.SSH, t.Web = max(t.SSH, est.SSH), max(t.Web, est.Web)
return t
}