feat: HTTP protocol plugin + XDP globals patching from config

protocol-http (compile-time feature):
- HttpHandler: incremental HTTP/1.1 request parse (fragment-safe),
  header size/timeout limits, method whitelist, Host required,
  blocked_paths, optional User-Agent requirement
- [protocol.http] config section; registry wiring behind feature

XDP globals:
- src/xdp/globals.rs: XdpGlobals + build_rodata_image() mirroring
  xdp/core/config.h layout; set via OpenMapMut::set_initial_value()
  before load ([xdp] section: ports, udp policy, throttle, challenge)
- wire set_globals into rampart binary startup

fix: gate preflight() behind xdp feature (dead code without it)
This commit is contained in:
Loki 2026-08-24 12:18:22 +02:00
parent 8b35ac693c
commit 6863249ad4
Signed by: boba
GPG key ID: 253067914055423B
14 changed files with 972 additions and 22 deletions

View file

@ -5,6 +5,8 @@ pub use sections::{
BackendConfig, BanConfig, BindConfig, DetectAlertConfig, DetectAutobanConfig, DetectConfig, DetectPrefixConfig,
LimitsConfig, LoggingConfig, MetricsConfig, PowConfig, StoreConfig, WorkerConfig, XdpConfig,
};
#[cfg(feature = "protocol-http")]
pub use sections::{HttpProtocolConfig, ProtocolConfig};
use serde::Deserialize;
use std::fs;
@ -33,6 +35,9 @@ pub struct Config {
pub pow: PowConfig,
#[serde(default)]
pub detect: DetectConfig,
#[cfg(feature = "protocol-http")]
#[serde(default)]
pub protocol: ProtocolConfig,
#[serde(default)]
pub whitelist: Vec<String>,
}
@ -75,6 +80,15 @@ impl Config {
if self.detect.prefix.enabled && self.detect.prefix.syn_threshold == 0 {
anyhow::bail!("detect.prefix.syn_threshold must be positive when enabled");
}
#[cfg(feature = "protocol-http")]
{
if self.protocol.http.max_header_bytes == 0 {
anyhow::bail!("protocol.http.max_header_bytes must be positive");
}
if self.protocol.http.timeout_secs == 0 {
anyhow::bail!("protocol.http.timeout_secs must be positive");
}
}
Ok(())
}
}