this so the app runs on router reboot

This commit is contained in:
lda
2025-09-28 16:03:47 +07:00 Unverified
parent 799c719999
commit 9ffe4fc85b
7 changed files with 17 additions and 10 deletions
+4 -3
View File
@@ -1,6 +1,6 @@
use crate::{
arpparse::NUDState,
utils::parse::{de_many, serialize_macs},
utils::{parse::{de_many, serialize_macs}, query::get_macs},
};
use axum::{Json, http::StatusCode, response::IntoResponse};
use axum_extra::extract::Query;
@@ -93,9 +93,10 @@ pub async fn get_status_json(
mac: mac.clone(),
};
let mut tasks = Vec::new();
// can we jus collect the whole table instead of doing this.
for d in &dev_opts {
for n in &nud_opts {
tasks.push(crate::utils::query::get_macs(
tasks.push(get_macs( // this i hate sm
name.as_deref(),
ips_opt.as_deref(),
d.as_deref(),
@@ -109,7 +110,7 @@ pub async fn get_status_json(
.map(|v| v.into_iter().flatten().collect::<Vec<_>>())
{
Ok(mut table) => {
if !mac.is_empty() {
if !mac.is_empty() { // mac here
let wanted: HashSet<MacAddr> = mac.into_iter().collect();
table.retain(|row| row.mac.map(|m| wanted.contains(&m)).unwrap_or(false));
}
+1 -1
View File
@@ -89,7 +89,7 @@ pub async fn wake_multi_split(
} else {
wake_one(
&sock,
c.try_into().expect("complete struct failed to try_into"),
c.try_into().expect("complete struct failed to try_into"), // type state pattern?
)
.await
.into()
+1
View File
@@ -7,6 +7,7 @@ pub fn get_dev() -> HashSet<String> {
if e.file_type()
.map(|ft| {
if ft.is_symlink() {
// true
fs::metadata(e.path()).map(|m| m.is_dir()).unwrap_or(false)
} else {
ft.is_dir()
+4 -2
View File
@@ -81,7 +81,7 @@ pub async fn get_macs(
state: Option<NUDState>,
) -> Result<Vec<IpNeighLine>> {
let ip_list: Option<Vec<IpAddr>> =
ips.map(|slice| slice.iter().copied().map(|ip| ip.to_canonical()).collect());
ips.map(|slice| slice.iter().map(|ip| ip.to_canonical()).collect());
let ip_list = match (ip_list, machine_name) {
(Some(list), _) => list,
(None, Some(name)) => get_ips(name).await?.collect(),
@@ -136,7 +136,9 @@ pub async fn get_mac(
Ok(rows)
}
/* pub async fn _get_macs_good(
/*
/// get macs where you just run ip neigh then rust handles the filtering (faster than get mac)
pub async fn get_macs_rust(
machine_names: Option<&str>,
ips: Option<&[IpAddr]>,
devs: Option<&[&str]>,