Полностью доведена production-логика AWG2 harness по up2: strict execution, tc parser, anti-torrent, status и документация
This commit is contained in:
+21
-19
@@ -1,4 +1,4 @@
|
||||
use crate::{config::Config, docker, traffic, wg};
|
||||
use crate::{config::Config, docker, firewall, netns::build_transport, traffic, wg};
|
||||
|
||||
use std::{fs, process::Command};
|
||||
|
||||
@@ -54,6 +54,19 @@ pub fn print_status(cfg: &Config) -> anyhow::Result<()> {
|
||||
Err(e) => println!(" drift: unknown ({e})"),
|
||||
}
|
||||
|
||||
println!(" topology:");
|
||||
let transport = build_transport(target.container_pid, &target.container_name);
|
||||
let egress_qdisc = transport
|
||||
.run(&["tc", "qdisc", "show", "dev", &target.interface_name])
|
||||
.unwrap_or_default();
|
||||
let ingress_qdisc = egress_qdisc.clone();
|
||||
let ifb_qdisc = transport
|
||||
.run(&["tc", "qdisc", "show", "dev", &cfg.traffic.ifb_name])
|
||||
.unwrap_or_default();
|
||||
println!(" egress_htb_present: {}", egress_qdisc.contains("htb"));
|
||||
println!(" ingress_present: {}", ingress_qdisc.contains("ingress"));
|
||||
println!(" ifb_htb_present: {}", ifb_qdisc.contains("htb"));
|
||||
|
||||
println!("Anti-torrent:");
|
||||
println!(" enabled: {}", cfg.anti_torrent.enabled);
|
||||
println!(
|
||||
@@ -62,23 +75,13 @@ pub fn print_status(cfg: &Config) -> anyhow::Result<()> {
|
||||
);
|
||||
|
||||
if cfg.anti_torrent.enabled {
|
||||
let fw = Command::new("nsenter")
|
||||
.args([
|
||||
"-t",
|
||||
&target.container_pid.to_string(),
|
||||
"-n",
|
||||
"--",
|
||||
"nft",
|
||||
"list",
|
||||
"table",
|
||||
"inet",
|
||||
"awg2_harness",
|
||||
])
|
||||
.output();
|
||||
match fw {
|
||||
Ok(out) if out.status.success() => println!(" actual: table present"),
|
||||
Ok(_) => println!(" actual: table missing or drift"),
|
||||
Err(_) => println!(" actual: unable to inspect"),
|
||||
match firewall::antitorrent_drop_counter(cfg) {
|
||||
Ok(Some((packets, bytes))) => {
|
||||
println!(" dropped_packets: {}", packets);
|
||||
println!(" dropped_bytes: {}", bytes);
|
||||
}
|
||||
Ok(None) => println!(" dropped_packets: n/a"),
|
||||
Err(e) => println!(" dropped_packets: inspect error ({e})"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +113,3 @@ pub fn print_status(cfg: &Config) -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user