update and use ts shit idk anymore

This commit is contained in:
lda
2026-01-20 00:53:42 +07:00 Unverified
parent 059ce959f0
commit 56eab6dbb3
7 changed files with 283 additions and 268 deletions
+1
View File
@@ -5,6 +5,7 @@
//! lowk why its free but its indirection and its ass
pub mod json;
pub mod nl;
use crate::utils::serialize::mac::option_mac;
use macaddr::MacAddr;
+20
View File
@@ -0,0 +1,20 @@
//! i said i aint doing ts no more why am i still here
use futures::TryStreamExt;
use crate::subcommands::address::AddrOutput;
// shit this one is even worse you needa collect info from two places
pub async fn get(dev: Option<&str>) -> anyhow::Result<Vec<AddrOutput>> {
let (conn, handle, _) = rtnetlink::new_connection()?;
tokio::spawn(conn); // every time?
let mut address = handle.address().get();
let mut link = handle.link().get();
if let Some(dev) = dev {
link = link.match_name(dev.to_owned());
if let Some(ind) = link.execute().try_next().await?.map(|a| a.header.index) {
address = address.set_link_index_filter(ind);
}
};
todo!()
}
+3
View File
@@ -17,6 +17,7 @@ use rtnetlink::packet_route::{
use super::{NUDState, NeighborItem};
// dont you love https://github.com/rust-netlink/rtnetlink/blob/main/examples/get_neighbours.rs
// NeighborItem.state guarantees to be a single thing.
pub async fn get(
ip: Option<IpAddr>,
dev: Option<&str>,
@@ -27,6 +28,8 @@ pub async fn get(
tokio::spawn(conn); // every time?
let mut neighbor_data = handle.neighbours().get().execute();
let nudset: HashSet<&NUDState> = HashSet::from_iter(gnud);
// map ifindex to name
let mut ball: HashMap<u32, String> = HashMap::new();
let mut result = vec![];
'big: while let Some(neighbour_message_item) = neighbor_data.try_next().await? {