feat: bootstrap awg2 harness rust workspace and docs

This commit is contained in:
2026-05-09 02:17:25 +05:00
commit d937f816bf
47 changed files with 4195 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
use crate::{config::Config, docker::run_capture};
pub fn detect_interface(cfg: &Config, container: &str) -> anyhow::Result<String> {
for ifname in &cfg.amnezia.interface_candidates {
let ok = std::process::Command::new("docker")
.args(["exec", container, "ip", "link", "show", ifname])
.output()?;
if ok.status.success() {
return Ok(ifname.clone());
}
}
let links = run_capture(&[
"docker",
"exec",
container,
"sh",
"-c",
"ip -o link show | awk -F': ' '{print $2}'",
])?;
for raw in links.lines() {
let name = raw.trim();
for p in &cfg.amnezia.interface_patterns {
if glob_like_match(p, name) {
return Ok(name.to_string());
}
}
}
anyhow::bail!("unable to detect amnezia interface")
}
fn glob_like_match(pattern: &str, value: &str) -> bool {
if let Some(prefix) = pattern.strip_suffix('*') {
value.starts_with(prefix)
} else {
pattern == value
}
}