Полностью доведена production-логика AWG2 harness по up2: strict execution, tc parser, anti-torrent, status и документация
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user