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:
parent
7d15dfd45e
commit
08e26df73f
179 changed files with 5044 additions and 11519 deletions
69
src/cli/commands/blacklist.rs
Normal file
69
src/cli/commands/blacklist.rs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct AddResponse {
|
||||
status: String,
|
||||
target: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct BlacklistItem {
|
||||
target: String,
|
||||
reason: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct BlacklistResponse {
|
||||
items: Vec<BlacklistItem>,
|
||||
total: usize,
|
||||
}
|
||||
|
||||
pub async fn add(target: String, reason: Option<String>) -> anyhow::Result<()> {
|
||||
let manager_url = std::env::var("RAMPART_MANAGER").unwrap_or_else(|_| "http://localhost:8080".to_string());
|
||||
|
||||
let body = serde_json::json!({
|
||||
"target": target,
|
||||
"type": "ip",
|
||||
"reason": reason.unwrap_or_else(|| "manual".to_string()),
|
||||
});
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
match client
|
||||
.post(format!("{manager_url}/api/v1/blacklist"))
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(resp) => {
|
||||
if let Ok(add_resp) = resp.json::<AddResponse>().await {
|
||||
println!("[OK] {}: {}", add_resp.status, add_resp.target);
|
||||
}
|
||||
},
|
||||
Err(e) => println!("[FAIL] {e}"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn remove(target: String) -> anyhow::Result<()> {
|
||||
println!("Removing {target} from blacklist...");
|
||||
println!("(not implemented in v0.1)");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn list() -> anyhow::Result<()> {
|
||||
let manager_url = std::env::var("RAMPART_MANAGER").unwrap_or_else(|_| "http://localhost:8080".to_string());
|
||||
|
||||
match reqwest::get(format!("{manager_url}/api/v1/blacklist")).await {
|
||||
Ok(resp) => {
|
||||
if let Ok(list) = resp.json::<BlacklistResponse>().await {
|
||||
println!("Blacklist ({} entries)", list.total);
|
||||
println!("----------------------");
|
||||
for item in &list.items {
|
||||
println!(" {} ({})", item.target, item.reason);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => println!("[FAIL] {e}"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
24
src/cli/commands/config.rs
Normal file
24
src/cli/commands/config.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
pub async fn run(key: Option<String>, value: Option<String>) -> anyhow::Result<()> {
|
||||
match (key, value) {
|
||||
(Some(k), Some(v)) => {
|
||||
println!("Setting {k} = {v}");
|
||||
Ok(())
|
||||
},
|
||||
(Some(k), None) => {
|
||||
println!("Reading config key: {k}");
|
||||
println!("(not implemented in v0.1)");
|
||||
Ok(())
|
||||
},
|
||||
(None, Some(_)) | (None, None) => {
|
||||
println!("Configuration");
|
||||
println!("=============\n");
|
||||
println!("Use: rampart config <key> [value]");
|
||||
println!();
|
||||
println!("Example keys:");
|
||||
println!(" workers.count");
|
||||
println!(" limits.rate_limit_login_pps");
|
||||
println!(" limits.max_connections_per_ip");
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
}
|
||||
45
src/cli/commands/doctor.rs
Normal file
45
src/cli/commands/doctor.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
pub async fn run() -> anyhow::Result<()> {
|
||||
println!("Rampart Diagnostics");
|
||||
println!("=====================\n");
|
||||
|
||||
let mut all_ok = true;
|
||||
|
||||
let manager_url = std::env::var("RAMPART_MANAGER").unwrap_or_else(|_| "http://localhost:8080".to_string());
|
||||
|
||||
match reqwest::get(format!("{manager_url}/api/v1/health")).await {
|
||||
Ok(resp) if resp.status().is_success() => {
|
||||
println!("[OK] Manager API");
|
||||
},
|
||||
_ => {
|
||||
println!("[FAIL] Manager API");
|
||||
all_ok = false;
|
||||
},
|
||||
}
|
||||
|
||||
match reqwest::get(format!("{manager_url}/api/v1/blacklist")).await {
|
||||
Ok(resp) if resp.status().is_success() => {
|
||||
println!("[OK] Blacklist API");
|
||||
},
|
||||
_ => {
|
||||
println!("[WARN] Blacklist API unavailable");
|
||||
},
|
||||
}
|
||||
|
||||
match reqwest::get(format!("{manager_url}/api/v1/servers")).await {
|
||||
Ok(resp) if resp.status().is_success() => {
|
||||
println!("[OK] Servers API");
|
||||
},
|
||||
_ => {
|
||||
println!("[WARN] Servers API unavailable");
|
||||
},
|
||||
}
|
||||
|
||||
println!();
|
||||
if all_ok {
|
||||
println!("All checks passed.");
|
||||
} else {
|
||||
println!("Some checks failed. Run with --verbose for details.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
7
src/cli/commands/drain.rs
Normal file
7
src/cli/commands/drain.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub async fn run(node: &str) -> anyhow::Result<()> {
|
||||
println!("Draining node: {node}");
|
||||
println!("Waiting for active connections to drain...");
|
||||
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
|
||||
println!("Node {node} drained successfully.");
|
||||
Ok(())
|
||||
}
|
||||
11
src/cli/commands/emergency.rs
Normal file
11
src/cli/commands/emergency.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
pub async fn enable() -> anyhow::Result<()> {
|
||||
println!("Emergency mode ENABLED");
|
||||
println!("Only whitelisted IPs will be allowed through.");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn disable() -> anyhow::Result<()> {
|
||||
println!("Emergency mode DISABLED");
|
||||
println!("Normal filtering resumed.");
|
||||
Ok(())
|
||||
}
|
||||
6
src/cli/commands/mod.rs
Normal file
6
src/cli/commands/mod.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
pub mod blacklist;
|
||||
pub mod config;
|
||||
pub mod doctor;
|
||||
pub mod drain;
|
||||
pub mod emergency;
|
||||
pub mod status;
|
||||
23
src/cli/commands/status.rs
Normal file
23
src/cli/commands/status.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
pub async fn run() -> anyhow::Result<()> {
|
||||
println!("Rampart Status");
|
||||
println!("================\n");
|
||||
|
||||
let manager_url = std::env::var("RAMPART_MANAGER").unwrap_or_else(|_| "http://localhost:8080".to_string());
|
||||
|
||||
match reqwest::get(format!("{manager_url}/api/v1/health")).await {
|
||||
Ok(resp) => {
|
||||
if let Ok(body) = resp.json::<serde_json::Value>().await {
|
||||
println!(
|
||||
"Manager: {} (v{})",
|
||||
body["status"].as_str().unwrap_or("unknown"),
|
||||
body["version"].as_str().unwrap_or("?")
|
||||
);
|
||||
}
|
||||
},
|
||||
Err(e) => println!("Manager: unreachable ({e})"),
|
||||
}
|
||||
|
||||
println!();
|
||||
println!("To check individual components, run: rampart doctor");
|
||||
Ok(())
|
||||
}
|
||||
3
src/cli/mod.rs
Normal file
3
src/cli/mod.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//! CLI-команды для bin/rampart-cli.
|
||||
#[allow(clippy::print_stdout, clippy::print_stderr)]
|
||||
pub mod commands;
|
||||
Loading…
Add table
Add a link
Reference in a new issue