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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue