chat has a vision (idk the state i jus want to commit)
This commit is contained in:
+2
-1
@@ -12,8 +12,9 @@
|
|||||||
//!
|
//!
|
||||||
//! i also need to see devices and idk MAYBE maybe not MAYBE UHHHHHH maybe broadcast
|
//! 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 neighbor;
|
pub mod subcommands;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
// i want a generalized way to build and call
|
// i want a generalized way to build and call
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
//! 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};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// i dont include what i dont know about (almost all ts)
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
struct CommmonOutput {
|
||||||
|
ifindex: u32,
|
||||||
|
ifname: String,
|
||||||
|
/// i imagine UP or DOWN, unknown
|
||||||
|
operstate: String,
|
||||||
|
// 6 has a serde and the enum doesnt? why.
|
||||||
|
address: Option<MacAddr6>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug, Deserialize)]
|
||||||
|
struct AddrOutput {
|
||||||
|
#[serde(flatten)]
|
||||||
|
c: CommmonOutput,
|
||||||
|
addr_info: Vec<AddrInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// i be copying
|
||||||
|
// Raw JSON shape from ip -j -4 address show
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct AddrInfo {
|
||||||
|
family: Option<String>,
|
||||||
|
|
||||||
|
local: Option<String>,
|
||||||
|
prefixlen: Option<u8>,
|
||||||
|
|
||||||
|
broadcast: Option<String>,
|
||||||
|
|
||||||
|
scope: Option<String>,
|
||||||
|
label: Option<String>,
|
||||||
|
// many more exist; we only take what we need
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
pub mod neighbor;
|
||||||
|
pub mod address;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//! ```
|
//! ```bash
|
||||||
//! ip -j n s
|
//! ip -j n s
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
@@ -14,14 +14,15 @@ use strum::{Display, EnumString};
|
|||||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
||||||
pub struct NeighborInput {
|
pub struct NeighborInput {
|
||||||
/// supports only the last item (ignore), `to` keyword is optional
|
/// supports only the last item (ignore), `to` keyword is optional
|
||||||
to: IpAddr,
|
to: Option<IpAddr>,
|
||||||
/// supports only one item (it complains)
|
/// supports only one item (it complains if multiple)
|
||||||
dev: String, // im all for simplicity
|
dev: Option<String>, // im all for simplicity
|
||||||
/// takes multiple, has to have `nud` before bro or it will think you `to`
|
/// takes multiple, has to have `nud` before bro or it will think you `to`
|
||||||
nud: Vec<NUDState>,
|
nud: Vec<NUDState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// as input this must be lowercase. as output it is uppercase
|
// as input this must be lowercase. as output it is uppercase
|
||||||
|
/// docs for items come from a random ahh man website idk
|
||||||
#[derive(Debug, PartialEq, Eq, EnumString, Display, Clone, Copy, Hash, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, EnumString, Display, Clone, Copy, Hash, Serialize, Deserialize)]
|
||||||
#[strum(serialize_all = "lowercase", ascii_case_insensitive)]
|
#[strum(serialize_all = "lowercase", ascii_case_insensitive)]
|
||||||
#[serde(rename_all = "UPPERCASE")]
|
#[serde(rename_all = "UPPERCASE")]
|
||||||
@@ -59,8 +60,9 @@ pub enum NUDState {
|
|||||||
Failed,
|
Failed,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
|
||||||
|
|
||||||
|
/// everything i see
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
||||||
pub struct NeighborItem {
|
pub struct NeighborItem {
|
||||||
dst: IpAddr,
|
dst: IpAddr,
|
||||||
dev: String,
|
dev: String,
|
||||||
Reference in New Issue
Block a user