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 name: Option<String>,
ip: Option<IpAddr>,
#[serde(deserialize_with = "des_opm")]
#[serde(default, deserialize_with = "des_opm")]
mac: Option<MacAddr>,
}
#[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 tokio::{net::{TcpStream, ToSocketAddrs}, time::timeout};
+14 -11
View File
@@ -32,18 +32,21 @@ function loadName() {
}
/** @param {String} s NUD state */
function rankState(s) {
const key = String(s || "")
.trim()
.toUpperCase();
return (
{
Permanent: 5,
Reachable: 5,
Stale: 4,
Delay: 3,
Probe: 3,
Incomplete: 3,
Noarp: 2,
None: 1,
Failed: 0,
}[s.toUpperCase()] ?? 0
PERMANENT: 5,
REACHABLE: 5,
STALE: 4,
DELAY: 3,
PROBE: 3,
INCOMPLETE: 3,
NOARP: 2,
NONE: 1,
FAILED: 0,
}[key] ?? 0
);
}
@@ -81,7 +84,7 @@ async function fetchStatus(name) {
try {
const r = await fetch(`/api/status?name=${encodeURIComponent(name)}`);
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}`;
setPill("bad", "error");
return;