This commit is contained in:
lda
2025-12-07 16:03:38 +07:00 Unverified
parent fc6548e15c
commit af0682a1f0
7 changed files with 51 additions and 55 deletions
+13 -1
View File
@@ -24,7 +24,18 @@ pub async fn get(
if !output.status.success() {
bail!(String::from_utf8_lossy(&output.stderr).into_owned())
} else {
serde_json::from_slice(&output.stdout).context("Deserialize failed")
let mut fuckass: Vec<NeighborItem> =
serde_json::from_slice(&output.stdout).context("Deserialize failed")?;
// i hate ts.
if let Some(dev) = dev {
for item in &mut fuckass {
if item.dev.is_none() {
item.dev = Some(dev.to_owned());
}
}
};
Ok(fuckass)
}
}
@@ -33,6 +44,7 @@ pub async fn _get(ip: Option<IpAddr>, dev: Option<&str>, nud: &[NUDState]) -> io
cmd.args(["-j", "neigh", "show"]);
if let Some(ip) = ip {
// cmd.arg("to");
cmd.arg(ip.to_canonical().to_string());
};
+2 -1
View File
@@ -73,7 +73,8 @@ pub enum NUDState {
pub struct NeighborItem {
#[serde(rename(deserialize = "dst"))]
pub ip: IpAddr,
pub dev: String,
#[serde(default)]
pub dev: Option<String>,
#[serde(with = "option_mac", default, rename(deserialize = "lladdr"))]
pub mac: Option<MacAddr>,
#[serde(default)]
+2 -2
View File
@@ -93,7 +93,7 @@ pub async fn get(
name
};
let Some((ip, dev)) = ip.zip(dev) else {
let (Some(ip), Some(dev)) = (ip, dev) else {
continue 'big;
};
@@ -116,7 +116,7 @@ pub async fn get(
result.push(NeighborItem {
ip,
dev,
dev: Some(dev),
mac,
state,
});
+1 -1
View File
@@ -1,2 +1,2 @@
pub mod iter;
// pub mod iter;
pub mod serialize;