Полностью доведена production-логика AWG2 harness по up2: strict execution, tc parser, anti-torrent, status и документация

This commit is contained in:
2026-05-09 23:38:53 +05:00
parent e7818054e8
commit d9f140b3e0
18 changed files with 699 additions and 146 deletions
+23 -3
View File
@@ -88,7 +88,12 @@ impl Config {
}
fn check_host_tools(&self) -> anyhow::Result<()> {
let mut required = vec!["tc", "ip", "wg", "nsenter", "docker", "modprobe"];
let mut required = vec!["tc", "ip", "wg", "docker", "modprobe"];
if !crate::netns::nsenter_available() {
eprintln!("nsenter is not available, will use docker exec fallback");
} else {
required.push("nsenter");
}
if self.anti_torrent.enabled {
required.push("nft");
}
@@ -103,7 +108,23 @@ impl Config {
}
fn tool_exists(tool: &str) -> bool {
Command::new(tool).arg("--version").output().is_ok()
let probes: &[&[&str]] = match tool {
"tc" => &[&["-V"]],
"ip" => &[&["-V"], &["-Version"]],
"wg" => &[&["--version"]],
"docker" => &[&["--version"]],
"modprobe" => &[&["--version"]],
"nsenter" => &[&["--help"]],
"nft" => &[&["--version"]],
_ => &[&["--version"], &["--help"], &["-V"]],
};
for args in probes {
if Command::new(tool).args(*args).output().is_ok() {
return true;
}
}
false
}
pub fn parse_cidr_v4(cidr: &str) -> anyhow::Result<(Ipv4Addr, u8)> {
@@ -152,4 +173,3 @@ mod tests {
assert!(!no);
}
}