- XDP: prefix_stats LRU map, per-/24 (v4) and /64 (v6) SYN/packet counters, incremented post-blacklist/throttle (xdp/core/prefix_stats.h) - userspace: SubnetDetector escalation ladder Monitor->StrictLimit->Challenge->Block with spoof-gate (Block requires >= min_unique_sources, CGNAT-safe) - config: [detect.prefix] section (enabled=false by default) - fallback without XDP: engine SubnetTracker aggregates connections per-prefix - fix: PrefixStatsVal::from_bytes for xdp feature build; prefix_len 24 vs 64 cargo build/clippy(-D warnings, all features)/test green: 83 tests
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
use anyhow::{Ok, Result};
|
|
use std::net::{IpAddr, Ipv4Addr};
|
|
|
|
use crate::traffic::prefix::{PrefixKey, PrefixStatsVal};
|
|
|
|
pub struct XdpFilter;
|
|
|
|
impl XdpFilter {
|
|
pub fn new(_interface: &str) -> Self {
|
|
Self
|
|
}
|
|
pub fn load(&mut self) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
pub fn unload(&mut self) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
pub fn drain_events(&self) {}
|
|
pub fn ban_ip(&self, _ip: Ipv4Addr, _duration_secs: u64) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
pub fn ban_cidr(&self, _prefix: IpAddr, _prefix_len: u8, _duration_secs: u64) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
pub fn unban_ip(&self, _ip: Ipv4Addr) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
|
|
/// Честная ошибка: чтение `prefix_stats` не подключено без feature `xdp`.
|
|
///
|
|
/// # Errors
|
|
/// Всегда — сборка без XDP не имеет доступа к картам ядра.
|
|
pub fn read_prefix_stats(&self) -> Result<Vec<(PrefixKey, PrefixStatsVal)>> {
|
|
anyhow::bail!("prefix_stats reading not wired yet: built without xdp feature")
|
|
}
|
|
|
|
pub fn get_stats(&self) -> Result<super::XdpStats> {
|
|
Ok(super::XdpStats::default())
|
|
}
|
|
}
|