feat!: universal redesign — drop Minecraft stack, single-crate architecture

- remove Java plugins (velocity/paper), dashboard, all MC-specific code
  (handshake, death_code, varint, hostname-HMAC); available in history pre-v0.2
- merge crates/* into one package with src/bin/{rampart,rampart-manager,rampart-cli}
- ProtocolHandler trait + registry (no implementations yet), universal PoW kept
- XDP: universal L3/L4 filter (xdp/core/) + pluggable hook API (xdp/hooks/),
  fix IPv6 saddr bug; clang build verified
- docs: bilingual knowledge base (docs/kb/: attacks x4, defense-levels,
  practice x3), rewrite README/architecture for universal concept
- TODO.md v4.0: <=300-line module limit, competitor benchmark section (ref/)
- deploy/CI/docs cleanup: no MC references, new binary names

cargo build/clippy(-D warnings)/test green (55 tests)
This commit is contained in:
Loki 2026-08-24 01:50:22 +02:00
parent 7d15dfd45e
commit 08e26df73f
Signed by: boba
GPG key ID: 6CDE87BC9A778D97
179 changed files with 5044 additions and 11519 deletions

228
src/config/sections.rs Normal file
View file

@ -0,0 +1,228 @@
//! Секции единого конфига платформы.
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct BindConfig {
#[serde(default = "default_bind_address")]
pub address: String,
#[serde(default = "default_bind_port")]
pub port: u16,
}
impl Default for BindConfig {
fn default() -> Self {
Self {
address: default_bind_address(),
port: default_bind_port(),
}
}
}
fn default_bind_address() -> String {
"0.0.0.0".to_string()
}
fn default_bind_port() -> u16 {
25565
}
/// Generic upstream-бэкенды (список addr:port) за edge-нодой.
#[derive(Debug, Clone, Deserialize)]
pub struct BackendConfig {
#[serde(default = "default_upstreams")]
pub upstreams: Vec<String>,
}
impl Default for BackendConfig {
fn default() -> Self {
Self {
upstreams: default_upstreams(),
}
}
}
fn default_upstreams() -> Vec<String> {
vec!["127.0.0.1:25566".to_string()]
}
#[derive(Debug, Clone, Deserialize)]
pub struct WorkerConfig {
#[serde(default = "default_worker_count")]
pub count: usize,
}
impl Default for WorkerConfig {
fn default() -> Self {
Self { count: 4 }
}
}
fn default_worker_count() -> usize {
4
}
#[derive(Debug, Clone, Deserialize)]
pub struct LimitsConfig {
#[serde(default = "default_handshake_timeout")]
pub handshake_timeout_secs: u64,
#[serde(default = "default_max_connections_per_ip")]
pub max_connections_per_ip: u32,
#[serde(default = "default_rate_limit_pps")]
pub rate_limit_pps: f64,
#[serde(default = "default_rate_limit_burst")]
pub rate_limit_burst: f64,
}
impl Default for LimitsConfig {
fn default() -> Self {
Self {
handshake_timeout_secs: default_handshake_timeout(),
max_connections_per_ip: default_max_connections_per_ip(),
rate_limit_pps: default_rate_limit_pps(),
rate_limit_burst: default_rate_limit_burst(),
}
}
}
fn default_handshake_timeout() -> u64 {
5
}
fn default_max_connections_per_ip() -> u32 {
10
}
fn default_rate_limit_pps() -> f64 {
5.0
}
fn default_rate_limit_burst() -> f64 {
10.0
}
#[derive(Debug, Clone, Deserialize)]
pub struct BanConfig {
#[serde(default = "default_ban_duration")]
pub ban_duration_secs: u64,
}
impl Default for BanConfig {
fn default() -> Self {
Self {
ban_duration_secs: default_ban_duration(),
}
}
}
fn default_ban_duration() -> u64 {
3600
}
#[derive(Debug, Clone, Deserialize)]
pub struct StoreConfig {
pub redis_url: Option<String>,
#[serde(default = "default_blacklist_cache_ttl")]
pub blacklist_cache_ttl_secs: u64,
pub clickhouse_url: Option<String>,
}
impl Default for StoreConfig {
fn default() -> Self {
Self {
redis_url: None,
blacklist_cache_ttl_secs: default_blacklist_cache_ttl(),
clickhouse_url: None,
}
}
}
fn default_blacklist_cache_ttl() -> u64 {
300
}
#[derive(Debug, Clone, Deserialize)]
pub struct XdpConfig {
#[serde(default)]
pub enabled: bool,
#[serde(default = "default_xdp_interface")]
pub interface: String,
}
impl Default for XdpConfig {
fn default() -> Self {
Self {
enabled: false,
interface: default_xdp_interface(),
}
}
}
fn default_xdp_interface() -> String {
"eth0".to_string()
}
#[derive(Debug, Clone, Deserialize)]
pub struct LoggingConfig {
#[serde(default = "default_log_level")]
pub level: String,
#[serde(default = "default_log_format")]
pub format: String,
}
impl Default for LoggingConfig {
fn default() -> Self {
Self {
level: default_log_level(),
format: default_log_format(),
}
}
}
fn default_log_level() -> String {
"info".to_string()
}
fn default_log_format() -> String {
"text".to_string()
}
#[derive(Debug, Clone, Deserialize)]
pub struct MetricsConfig {
#[serde(default = "default_metrics_enabled")]
pub enabled: bool,
#[serde(default = "default_metrics_port")]
pub port: u16,
}
impl Default for MetricsConfig {
fn default() -> Self {
Self {
enabled: default_metrics_enabled(),
port: default_metrics_port(),
}
}
}
fn default_metrics_enabled() -> bool {
true
}
fn default_metrics_port() -> u16 {
9090
}
#[derive(Debug, Clone, Deserialize)]
pub struct PowConfig {
#[serde(default)]
pub enabled: bool,
#[serde(default = "default_pow_difficulty")]
pub difficulty: u8,
}
impl Default for PowConfig {
fn default() -> Self {
Self {
enabled: false,
difficulty: default_pow_difficulty(),
}
}
}
fn default_pow_difficulty() -> u8 {
4
}