wtf is this

This commit is contained in:
lda
2025-10-27 01:43:57 +07:00 Unverified
parent 0d9d800daf
commit efe557a72e
12 changed files with 86 additions and 9 deletions
+3
View File
@@ -0,0 +1,3 @@
trait IpCommand {
}
View File
+2 -2
View File
@@ -1,7 +1,7 @@
//! ts
//!
//!
//! deals with both ip a (addroutput) and ip l (commonoutput)
//!
//!
//! lowk why its free but its indirection and its ass
use macaddr::{MacAddr, MacAddr6};
+1 -1
View File
@@ -1,2 +1,2 @@
pub mod address;
pub mod neighbor;
pub mod address;
+25
View File
@@ -0,0 +1,25 @@
//! idk what to put here
use std::{iter, net::IpAddr};
use anyhow::bail;
use super::{NUDState, NeighborItem};
pub async fn get(
ip: Option<IpAddr>,
dev: Option<&str>,
nud: &[NUDState],
) -> anyhow::Result<Vec<NeighborItem>> {
let output = tokio::process::Command::new("ip")
.args(
(["-j", "neigh", "show"].iter().map(ToString::to_string))
.chain(ip.map(|ip| ip.to_canonical().to_string()))
.chain(dev.map(ToString::to_string))
.chain(nud.iter().map(|f| f.to_string())),
)
.output()
.await?;
bail!("no")
}
+2 -1
View File
@@ -4,6 +4,8 @@
//!
//! yes. this is a real call.
pub mod json;
use crate::utils::serialize::mac::{des_opm, ser_opm};
use std::net::IpAddr;
@@ -60,7 +62,6 @@ pub enum NUDState {
Failed,
}
/// everything i see
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
pub struct NeighborItem {
+35
View File
@@ -0,0 +1,35 @@
use std::iter::Fuse;
/// wrap ts into a [Fuse][std::iter::Fuse] or something
pub struct Real<A: Clone, B: Iterator<Item = A>> {
prepend: A,
iter: B,
my_turn: bool,
}
impl<A: Clone, B: Iterator<Item = A>> Real<A, B> {
pub fn new(prepend: A, iter: B) -> Self {
Self {
prepend,
iter,
my_turn: true,
}
}
pub fn fuse(prepend: A, iter: B) -> Fuse<Self> {
Self::new(prepend, iter).fuse()
}
}
impl<A: Clone, B: Iterator<Item = A>> Iterator for Real<A, B> {
type Item = A;
fn next(&mut self) -> Option<Self::Item> {
let a = if self.my_turn {
Some(self.prepend.clone())
} else {
self.iter.next()
};
self.my_turn = !self.my_turn;
a
}
}
+1
View File
@@ -1 +1,2 @@
pub mod iter;
pub mod serialize;
-1
View File
@@ -1,4 +1,3 @@
use macaddr::MacAddr;
use serde::{self, Deserialize, Deserializer, de::Error as DeError};
use serde::{Serialize, Serializer, de};