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 0b53ed720b
commit 15f474486a
Signed by: boba
GPG key ID: 253067914055423B
179 changed files with 5044 additions and 11519 deletions

View file

@ -0,0 +1,44 @@
use crate::manager::AppState;
use redis::AsyncCommands;
use std::sync::Arc;
use tokio::time::{Duration, interval};
pub async fn start_heartbeat_check(state: Arc<AppState>) {
let mut ticker = interval(Duration::from_secs(30));
loop {
ticker.tick().await;
if let Err(e) = check_nodes(&state).await {
tracing::warn!("heartbeat check failed: {e}");
}
}
}
async fn check_nodes(state: &AppState) -> anyhow::Result<()> {
let mut conn = state.redis_client.get_multiplexed_async_connection().await?;
let keys: Vec<String> = redis::cmd("KEYS").arg("rampart:nodes:*").query_async(&mut conn).await?;
let now = chrono::Utc::now().timestamp();
for key in &keys {
let raw: Option<String> = conn.get(key).await?;
if let Some(json) = raw
&& let Ok(mut node) = serde_json::from_str::<serde_json::Value>(&json)
{
let hb = node["last_heartbeat"]
.as_str()
.and_then(|s| chrono::DateTime::parse_from_rfc3339(s).ok())
.map(|t| t.timestamp())
.unwrap_or(0);
if now - hb > 60 {
if let Some(obj) = node.as_object_mut() {
obj.insert("status".to_string(), serde_json::Value::String("offline".to_string()));
if let Ok(updated) = serde_json::to_string(&node) {
let _: () = conn.set(key.as_str(), updated).await.unwrap_or_default();
}
}
tracing::warn!("Node {key} is offline (heartbeat expired)");
}
}
}
Ok(())
}