- 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)
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use crate::manager::AppState;
|
|
use axum::{Json, extract::State};
|
|
use redis::AsyncCommands;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct NodeInfo {
|
|
pub id: String,
|
|
pub role: String,
|
|
pub ip: String,
|
|
pub status: String,
|
|
pub last_heartbeat: String,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct NodesResponse {
|
|
pub nodes: Vec<NodeInfo>,
|
|
}
|
|
|
|
pub async fn list_nodes(State(state): State<Arc<AppState>>) -> Json<NodesResponse> {
|
|
let mut conn = match state.redis_client.get_multiplexed_async_connection().await {
|
|
Ok(c) => c,
|
|
Err(_) => return Json(NodesResponse { nodes: vec![] }),
|
|
};
|
|
|
|
let keys: Vec<String> = match redis::cmd("KEYS").arg("rampart:nodes:*").query_async(&mut conn).await {
|
|
Ok(k) => k,
|
|
Err(_) => return Json(NodesResponse { nodes: vec![] }),
|
|
};
|
|
|
|
let mut nodes = Vec::with_capacity(keys.len());
|
|
for key in &keys {
|
|
let raw: Option<String> = conn.get(key).await.unwrap_or(None);
|
|
if let Some(json) = raw
|
|
&& let Ok(node) = serde_json::from_str::<NodeInfo>(&json)
|
|
{
|
|
nodes.push(node);
|
|
}
|
|
}
|
|
|
|
Json(NodesResponse { nodes })
|
|
}
|