fix: never ban a trusted proxy network from any ban source

The gateway already refused to ban addresses from proxy_protocol.trusted_cidrs,
but the traffic-intelligence auto-ban and the subnet monitor still did, so a
trusted load balancer living inside a banned /24 (or below the reputation
threshold) could be knocked out together with its clients.

- TrustedProxyCidr moved to src/config/trusted.rs (the edge section file hit
  the 250-line gate) and gained `overlaps_prefix`: a ban is suppressed when the
  banned prefix intersects a trusted network.
- TrafficHook::with_trusted suppresses reputation and offender bans; its ban()
  now reports whether the ban was installed so `ban_offenders` counts real
  bans.
- The subnet monitor takes a MonitorSetup bundle (spawn had 8 arguments) and
  suppresses both userspace CIDR bans and XDP prefix bans that overlap a
  trusted network, logging a warning instead.
- IPv4-mapped addresses are normalised in `contains` too.
- Tests: overlap maths (v4/v6, /0 rejected), tracker suppression vs unrelated
  networks, and auto-ban skipping a trusted range while still banning public
  offenders.
This commit is contained in:
Loki 2026-11-16 13:03:50 +01:00
parent 72c1f45d62
commit bcae8901c6
Signed by: boba
GPG key ID: 6CDE87BC9A778D97
11 changed files with 300 additions and 106 deletions

View file

@ -287,9 +287,10 @@ module-size, secrets, `cargo deny`, rustdoc без warning'ов, clang+verifier,
### Осталось
- [ ] Monitor (`add_cidr`) и `traffic/hook` autoban не сверяются с `trusted_cidrs`: если
доверенный прокси физически живёт в банимой подсети, его адрес может попасть под
префиксный бан. Нужна общая проверка перед любым баном.
- [x] Monitor (`add_cidr`) и `traffic/hook` autoban сверяются с `trusted_cidrs`: бан
подавляется, если префикс пересекается с доверенной сетью (`TrustedProxyCidr::overlaps_prefix`),
о чём пишется warn. Тесты: `tests/subnet_detection.rs`, `tests/traffic_intel.rs`,
`tests/proxy_identity.rs`.
### Сделано в этом раунде