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

+13 -2
View File
@@ -35,7 +35,7 @@ func newEnforce(c Config, st *store.Store, peers []fed.Peer, en enricher, ready
}
}
e := enforce.New(enforce.Config{
Mode: mode, Path: c.EnforceLog, StatePath: filepath.Join(c.DataDir, "enforce.json"), Host: c.Name,
Mode: mode, Path: c.EnforceLog, UnbanPath: c.EnforceUnbanLog, StatePath: filepath.Join(c.DataDir, "enforce.json"), Host: c.Name,
Threshold: c.EnforceThreshold, MaxPerMin: c.EnforceMaxPerMin, Share: strings.EqualFold(c.EnforceShare, "on"),
Trusted: trusted, PeerHosts: hosts, InfraHosts: hosts, Resolve: resolveHost,
Crawler: func(ip string, uas []string) bool { v := st.FCrDNS(ip, uas); return v != nil && *v },
@@ -45,7 +45,7 @@ func newEnforce(c Config, st *store.Store, peers []fed.Peer, en enricher, ready
rows := st.AttackRoster(from)
out := make([]enforce.Seen, len(rows))
for i, r := range rows {
out[i] = enforce.Seen{IP: r.IP, Score: r.Score, Level: r.Level, Jails: r.Jails}
out[i] = enforce.Seen{IP: r.IP, Score: r.Score, Level: r.Level, Jails: r.Jails, Est: enforce.Tally{SSH: r.Est.SSH, Web: r.Est.Web}}
}
return out
},
@@ -90,6 +90,7 @@ func resolveHost(h string) []netip.Addr {
func shareDecisions(ctx context.Context, hub *fed.Hub, e *enforce.Engine, log *slog.Logger) {
pulled := map[string]int64{}
pushed := map[string]int64{}
pushedUn := map[string]int64{}
t := time.NewTicker(30 * time.Second)
defer t.Stop()
for {
@@ -112,6 +113,16 @@ func shareDecisions(ctx context.Context, hub *fed.Hub, e *enforce.Engine, log *s
}
}
}
for _, p := range hub.Peers {
if mine := e.UnbansSince(pushedUn[p.Name]); len(mine) > 0 {
start := time.Now().Unix()
if err := hub.PostJSON(ctx, p, "/api/v1/peer/unban?from="+url.QueryEscape(e.Host()), map[string]any{"unbans": mine}); err == nil {
pushedUn[p.Name] = start
} else if ctx.Err() == nil {
log.Debug("enforce: unban push failed", "peer", p.Name, "err", err)
}
}
}
select {
case <-ctx.Done():
return