v0.3: 6-layer architecture complete
Layers: Layer 1: XDP/eBPF — TCP state machine, SYN throttle, blacklist, ringbuf Layer 2: PoW Challenge — SHA-256 hashcash, dynamic difficulty, constant-time verify Layer 3: Rust Core — HMAC handshake, rate limit, death code (existing) Layer 4: Velocity — Physics check, CAPTCHA, protocol verification Layer 5: Paper — Heartbeat, auto-registration (existing) Layer 6: Traffic Intel — EWMA, 168h profiling, reputation, alerts Infra: XDP→Prometheus metrics, ClickHouse + Grafana dashboard, Docker Compose Testing: 100-IP DDoS simulation, MHDDoS ref analysis, load test report Fixes: VarInt sign extension UB, pure ACK deadlock, RST/FIN cleanup Ref: MHDDoS, Sonar, LimboFilter, AtomGuard, Infrarust, MC-XDP-eBPF, PowGo
This commit is contained in:
parent
414d3be659
commit
6d76a7eeb1
66 changed files with 4529 additions and 1003 deletions
50
crates/rampart-core/src/xdp/metrics.rs
Normal file
50
crates/rampart-core/src/xdp/metrics.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use anyhow::{Context, Result};
|
||||
use prometheus::{IntGauge, register};
|
||||
|
||||
use super::XdpStats;
|
||||
|
||||
pub struct XdpMetrics {
|
||||
total: IntGauge,
|
||||
tcp_mc: IntGauge,
|
||||
whitelist: IntGauge,
|
||||
blacklist: IntGauge,
|
||||
syn_throttle: IntGauge,
|
||||
passed: IntGauge,
|
||||
dropped: IntGauge,
|
||||
verified: IntGauge,
|
||||
}
|
||||
|
||||
impl XdpMetrics {
|
||||
fn new_gauge(name: &str, help: &str) -> Result<IntGauge> {
|
||||
let gauge = IntGauge::new(name, help)?;
|
||||
register(Box::new(gauge.clone())).context(format!("failed to register {name}"))?;
|
||||
Ok(gauge)
|
||||
}
|
||||
|
||||
pub fn register() -> Result<Self> {
|
||||
let m = Self {
|
||||
total: Self::new_gauge("rampart_xdp_total", "Total XDP packets processed")?,
|
||||
tcp_mc: Self::new_gauge("rampart_xdp_tcp_mc", "TCP packets matched to Minecraft profile")?,
|
||||
whitelist: Self::new_gauge("rampart_xdp_whitelist", "Whitelisted packets")?,
|
||||
blacklist: Self::new_gauge("rampart_xdp_blacklist", "Blacklisted packets")?,
|
||||
syn_throttle: Self::new_gauge("rampart_xdp_syn_throttle", "SYN packets rate-limited")?,
|
||||
passed: Self::new_gauge("rampart_xdp_passed", "Packets passed to upper layers")?,
|
||||
dropped: Self::new_gauge("rampart_xdp_dropped", "Packets dropped by filter")?,
|
||||
verified: Self::new_gauge("rampart_xdp_verified", "Packets challenge-verified")?,
|
||||
};
|
||||
tracing::info!("XDP Prometheus metrics registered");
|
||||
Ok(m)
|
||||
}
|
||||
|
||||
pub fn update(&self, stats: &XdpStats) {
|
||||
self.total.set(stats.total as i64);
|
||||
self.tcp_mc.set(stats.tcp_mc as i64);
|
||||
self.whitelist.set(stats.whitelist as i64);
|
||||
self.blacklist.set(stats.blacklist as i64);
|
||||
self.syn_throttle.set(stats.syn_throttle as i64);
|
||||
self.passed.set(stats.passed as i64);
|
||||
self.dropped.set(stats.dropped as i64);
|
||||
self.verified.set(stats.verified as i64);
|
||||
tracing::debug!("XDP metrics updated");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue