pub fn is_root() -> bool {
std::fs::read_to_string("/proc/self/status").is_ok_and(|status| {
status
.lines()
.find(|line| line.starts_with("Uid:"))
.and_then(|line| line.split_whitespace().nth(2))
== Some("0")
})
}
pub fn iface_exists(iface: &str) -> bool {
let needle = format!("{iface}:");
std::fs::read_to_string("/proc/net/dev").is_ok_and(|dev| {
dev.lines()
.any(|line| line.trim_start().starts_with(&needle))
})
}