Shared wire-format types and collectors for NetWatch Cloud — the SDK consumed by netwatch-agent and the NetWatch Cloud server. Parses /proc, ss, lsof, nettop, and libpcap events into a common Snapshot payload.
usestd::fs;usestd::process::Command;pubfndetect_gateway()->Option<String>{// Linux: `ip route`
ifletOk(output)=Command::new("ip").args(["route"]).output(){let text =String::from_utf8_lossy(&output.stdout);for line in text.lines(){if line.starts_with("default via "){return line.split_whitespace().nth(2).map(|s|s.to_string());}}}// macOS fallback: `netstat -rn`
ifletOk(output)=Command::new("netstat").args(["-rn"]).output(){let text =String::from_utf8_lossy(&output.stdout);for line in text.lines(){let cols:Vec<&str>= line.split_whitespace().collect();if cols.len()>=2&& cols[0]=="default"{returnSome(cols[1].to_string());}}}None}pubfndetect_dns()->Option<String>{ifletOk(contents)=fs::read_to_string("/etc/resolv.conf"){for line in contents.lines(){let trimmed = line.trim();if trimmed.starts_with("nameserver "){ifletSome(addr)= trimmed.split_whitespace().nth(1){returnSome(addr.to_string());}}}}None}