This commit is contained in:
lda
2025-08-24 21:15:55 +07:00 Unverified
parent 811116715c
commit 9346349b43
3 changed files with 17 additions and 12 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ pub fn home_2_route() -> Router {
pub struct DeviceQuery { pub struct DeviceQuery {
pub name: Option<String>, pub name: Option<String>,
ip: Option<IpAddr>, ip: Option<IpAddr>,
#[serde(deserialize_with = "des_opm")] #[serde(default, deserialize_with = "des_opm")]
mac: Option<MacAddr>, mac: Option<MacAddr>,
} }
#[derive(Debug, Default, Clone, Hash, serde::Deserialize)] #[derive(Debug, Default, Clone, Hash, serde::Deserialize)]
+2
View File
@@ -1,3 +1,5 @@
// this ENTIRE file is redundant... or?
use std::time::Duration; use std::time::Duration;
use tokio::{net::{TcpStream, ToSocketAddrs}, time::timeout}; use tokio::{net::{TcpStream, ToSocketAddrs}, time::timeout};
+14 -11
View File
@@ -32,18 +32,21 @@ function loadName() {
} }
/** @param {String} s NUD state */ /** @param {String} s NUD state */
function rankState(s) { function rankState(s) {
const key = String(s || "")
.trim()
.toUpperCase();
return ( return (
{ {
Permanent: 5, PERMANENT: 5,
Reachable: 5, REACHABLE: 5,
Stale: 4, STALE: 4,
Delay: 3, DELAY: 3,
Probe: 3, PROBE: 3,
Incomplete: 3, INCOMPLETE: 3,
Noarp: 2, NOARP: 2,
None: 1, NONE: 1,
Failed: 0, FAILED: 0,
}[s.toUpperCase()] ?? 0 }[key] ?? 0
); );
} }
@@ -81,7 +84,7 @@ async function fetchStatus(name) {
try { try {
const r = await fetch(`/api/status?name=${encodeURIComponent(name)}`); const r = await fetch(`/api/status?name=${encodeURIComponent(name)}`);
if (!r.ok) { if (!r.ok) {
const err = await r.json().catch(() => ({})); const err = await r.json().catch((_) => (elHtml.textContent = r.text));
elLog.textContent = `status error: ${err.error || r.status}`; elLog.textContent = `status error: ${err.error || r.status}`;
setPill("bad", "error"); setPill("bad", "error");
return; return;