feat(ingress): firewall telemetry of inbound attempts (host kit --ingress)

Observation-only nftables table (prerouting -150, counters and a
rate-limited log, never drops or modifies), a per-minute counters file,
probe sources ingress and ingresscnt, a per-host hourly aggregate in the
hub (exact totals, sampled ports/ASNs/countries, banned share by the
hub's own ban state, no ban feedback loop), GET /api/v1/ingress, a
Defense section, doctor check, docs EN/pt-BR and tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-23 09:09:16 -03:00
1 parent 4143bf599e
commit aefdcea8d2
40 files changed
+1684 -11

No files matched your search

+10
View File
@@ -115,6 +115,9 @@ type Runner struct {
Log *slog.Logger
// EgressFeed receives the "egress" lines of a probe (nil: they are only counted).
EgressFeed func(line []byte)
// IngressFeed receives the "ingress" and "ingresscnt" lines of a probe
// (nil: they are only counted). They never become events.
IngressFeed func(src string, line []byte)
mu sync.Mutex // commit mutex: held while a line is applied and by snapshots
@@ -236,6 +239,13 @@ func (r *Runner) feedLocked(src string, text []byte, end store.Offset) bool {
r.EgressFeed(text)
}()
}
} else if src == wire.SrcIngress || src == wire.SrcIngressCnt {
if r.IngressFeed != nil {
func() {
defer func() { recover() }()
r.IngressFeed(src, text)
}()
}
} else if s := r.find(name); s != nil {
r.handle(s)(text)
}