- xdp: real 24-byte xdp_event parsing (fixes LE byte-swap of src IP), opt-in [xdp] auto_ban (RATE_LIMIT always, CONN_DROP at fails>=threshold; EVENT_BAN/POLICY_DROP excluded by design), rampart_xdp_autobans_total; wired in app before load(); 10 tests in tests/xdp_events.rs - build: --no-default-features compiles — redis paths cfg-gated behind store-redis, manager fail-fasts without it; CI gates the config now - app: RunExit enum replaces process::exit in lib; single exit site in main - tests: seed PoW roundtrip token (was ~1/16 flaky; 50 pre-fix fails -> 0) - docs: TODO statuses refreshed (round 2)
20 lines
1 KiB
Rust
20 lines
1 KiB
Rust
//! Prometheus-метрики загрузчика XDP.
|
|
//!
|
|
//! Регистрируются в глобальный реестр `prometheus` (тот же, что собирает
|
|
//! `prometheus::gather()` в `crate::metrics::run_metrics_server`), поэтому
|
|
//! endpoint `/metrics` подхватывает их без правок вне `src/xdp/`.
|
|
|
|
use prometheus::{IntCounter, register_int_counter};
|
|
use std::sync::LazyLock;
|
|
|
|
/// Сколько раз событие XDP-ringbuf привело к userspace-авто-бану
|
|
/// (счётчик инкрементится только на НОВЫЙ бан, не на продление).
|
|
pub static XDP_AUTOBANS_TOTAL: LazyLock<IntCounter> = LazyLock::new(|| {
|
|
register_int_counter!("rampart_xdp_autobans_total", "Auto-bans issued from XDP ringbuf events")
|
|
.expect("XDP_AUTOBANS_TOTAL")
|
|
});
|
|
|
|
/// Форсирует регистрацию счётчика (для вызова на старте загрузки XDP).
|
|
pub fn init() {
|
|
LazyLock::force(&XDP_AUTOBANS_TOTAL);
|
|
}
|