Feature Flags and shit codex did idfk
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
//! i also need to see devices and idk MAYBE maybe not MAYBE UHHHHHH maybe broadcast
|
||||
//!
|
||||
//! LOWK if this were to be calls to kernel or some bullshit then PLEASE because doing ts parsing its hell cuh
|
||||
|
||||
pub mod subcommands;
|
||||
pub mod utils;
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
//! lowk why its free but its indirection and its ass
|
||||
|
||||
pub mod json;
|
||||
#[cfg(all(unix, feature = "experimental-nl"))]
|
||||
pub mod nl;
|
||||
|
||||
pub use crate::subcommands::Backend;
|
||||
use crate::utils::serialize::mac::option_mac;
|
||||
use macaddr::MacAddr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -40,3 +42,18 @@ pub struct AddrInfo {
|
||||
pub label: Option<String>,
|
||||
// many more exist; we only take what we need
|
||||
}
|
||||
|
||||
pub async fn get(dev: Option<&str>) -> anyhow::Result<Vec<AddrOutput>> {
|
||||
get_with_backend(Backend::Json, dev).await
|
||||
}
|
||||
|
||||
pub async fn get_with_backend(
|
||||
backend: Backend,
|
||||
dev: Option<&str>,
|
||||
) -> anyhow::Result<Vec<AddrOutput>> {
|
||||
match backend {
|
||||
Backend::Json => json::get(dev).await,
|
||||
#[cfg(all(unix, feature = "experimental-nl"))]
|
||||
Backend::Netlink => nl::get(dev).await,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! i said i aint doing ts no more why am i still here
|
||||
|
||||
#![cfg(unix)]
|
||||
use futures::TryStreamExt;
|
||||
|
||||
use crate::subcommands::address::AddrOutput;
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
pub mod address;
|
||||
pub mod neighbor;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Backend {
|
||||
Json,
|
||||
#[cfg(all(unix, feature = "experimental-nl"))]
|
||||
Netlink,
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
//! yes. this is a real call.
|
||||
|
||||
pub mod json;
|
||||
#[cfg(all(unix, feature = "experimental-nl"))]
|
||||
pub mod nl;
|
||||
|
||||
pub use crate::subcommands::Backend;
|
||||
use crate::utils::serialize::mac::option_mac;
|
||||
use std::net::IpAddr;
|
||||
|
||||
@@ -80,3 +82,28 @@ pub struct NeighborItem {
|
||||
#[serde(default)]
|
||||
pub state: Vec<NUDState>,
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
ip: Option<IpAddr>,
|
||||
dev: Option<&str>,
|
||||
nud: &[NUDState],
|
||||
) -> anyhow::Result<Vec<NeighborItem>> {
|
||||
get_with_backend(Backend::Json, ip, dev, nud).await
|
||||
}
|
||||
|
||||
pub async fn get_with_backend(
|
||||
backend: Backend,
|
||||
ip: Option<IpAddr>,
|
||||
dev: Option<&str>,
|
||||
nud: &[NUDState],
|
||||
) -> anyhow::Result<Vec<NeighborItem>> {
|
||||
match backend {
|
||||
Backend::Json => json::get(ip, dev, nud).await,
|
||||
#[cfg(all(unix, feature = "experimental-nl"))]
|
||||
Backend::Netlink => {
|
||||
let ips: Vec<IpAddr> = ip.into_iter().collect();
|
||||
let devs: Vec<&str> = dev.into_iter().collect();
|
||||
nl::get(&ips, &devs, nud, &[]).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! rtnetlink-based neighbor table query. One syscall, filter in userspace.
|
||||
|
||||
#![cfg(unix)]
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
net::IpAddr,
|
||||
|
||||
Reference in New Issue
Block a user