Compare commits
8
Commits
v0.1.6
..
1307cec52b
No files matched your search
@@ -3,8 +3,3 @@ target = "armv7-unknown-linux-musleabihf"
|
||||
|
||||
[target.armv7-unknown-linux-musleabihf]
|
||||
linker = "rust-lld"
|
||||
|
||||
[alias]
|
||||
ldabr = "b -r --target=target.armv7-unknown-linux-musleabihf"
|
||||
t = "test -- --nocapture --test-threads=1"
|
||||
tdebug = "test -- --nocapture --test-threads=1 --show-output"
|
||||
File renamed without changes.
@@ -1,10 +1,8 @@
|
||||
you should use block code to refence code, like so:
|
||||
|
||||
```rust
|
||||
hello_world!(println);
|
||||
// indented lines
|
||||
```
|
||||
|
||||
in the chat. Else it fucks up formatting.
|
||||
|
||||
We work towards clean, maintainable design. im not the best at this thing.
|
||||
Generated
+1
-1
@@ -1179,7 +1179,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "wakey"
|
||||
version = "0.1.6"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-extra",
|
||||
|
||||
+3
-9
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wakey"
|
||||
version = "0.1.6"
|
||||
version = "0.1.5"
|
||||
edition = "2024"
|
||||
publish = ["gitea"]
|
||||
|
||||
@@ -16,12 +16,7 @@ serde_json = "1.0.143"
|
||||
serde_with = { version = "3.14.0", features = ["json"] }
|
||||
strum = { version = "0.27.2", features = ["derive", "strum_macros"] }
|
||||
thiserror = "2.0.16"
|
||||
tokio = { version = "1.47.1", features = [
|
||||
"fs",
|
||||
"process",
|
||||
"rt-multi-thread",
|
||||
"io-util",
|
||||
] }
|
||||
tokio = { version = "1.47.1", features = ["fs", "process", "rt-multi-thread", "io-util"] }
|
||||
urlencoding = "2.1.3"
|
||||
|
||||
[profile.release]
|
||||
@@ -30,5 +25,4 @@ strip = true
|
||||
|
||||
[features]
|
||||
default = ["very-smart-parsing"]
|
||||
very-smart-parsing = [
|
||||
] # this is the a-bit-redundant parse thing that copilot made
|
||||
very-smart-parsing = [] # this is the a-bit-redundant parse thing that copilot made
|
||||
@@ -0,0 +1,60 @@
|
||||
# taking back my code AHHHH
|
||||
|
||||
this is going to be lengthy. ci is spotless but idk how it works cuz powershell. this is good but i cant afford VPN on the router; we will need to do some bullshit.
|
||||
|
||||
## overview
|
||||
|
||||
we need a:
|
||||
|
||||
- small ahh bin in the router.
|
||||
- forwards a shell and some functions.
|
||||
- may be shell calling fns maybe some unsafe c. i cant unsafe c.
|
||||
- big ahh bin in the vps.
|
||||
- connect to the small ahh bin thru the wide ass internet.
|
||||
- forwards some APIs.
|
||||
- static site
|
||||
- now need no hosts; apis can be called anywhere anyway.
|
||||
- do offer these in the big ahh bins tho lets not miss out some shit.
|
||||
- automation
|
||||
- gitea
|
||||
- on the vps or the uh idk.
|
||||
- ABSOLUTELY can auto build main:latest every day / other day.
|
||||
- and releases.
|
||||
- router
|
||||
- a script to pull the tar. from actions artifacts or from releases. (lua or shell yo)
|
||||
- a script for the bin and the init.d scripts for these two.
|
||||
- vps
|
||||
- a systemd service (ima use ai for ts ngl)
|
||||
- an auto updater. maybe we overkill and dnf. maybe go easy and git clone + cargo install. maybe we pull from release or nightly. idk
|
||||
|
||||
i think idk
|
||||
|
||||
## router
|
||||
|
||||
### current
|
||||
|
||||
everything.
|
||||
|
||||
we have some functions that call ip neigh a bajillion times.
|
||||
we have some other functions that read the same file/folder in /sys or sum shit.
|
||||
we have a function that broadcast to a set ahh address.
|
||||
|
||||
we have some routes; and some data structures acting as schema for them ahh. we dont do posts with json but gets with query strings for some ahh reasons.
|
||||
|
||||
these are carryover from the early days.
|
||||
|
||||
also from the early days are the js.
|
||||
|
||||
static was 100% ai with 0 intervention.
|
||||
|
||||
we have a search bar of sort that hooks through a smart endpoint that searches for everything.
|
||||
|
||||
we have some bullshit. and two buttons to check and wake. that pings `/api/smart/{query}` and `/wake?name=query`. why.
|
||||
we have the result of the wake and or status and the errors in the first text box.
|
||||
|
||||
the list of cliets with names connected to the router the second box.
|
||||
thats cool.
|
||||
|
||||
### changes?
|
||||
|
||||
idk changes.
|
||||
@@ -6,7 +6,6 @@ pub mod status;
|
||||
pub mod wake;
|
||||
|
||||
use crate::assets;
|
||||
use crate::dhcpparse::load_mac_name_cache;
|
||||
use crate::route::api::ip;
|
||||
use crate::route::api::status_redirect;
|
||||
use crate::route::api::status_smart_redirect;
|
||||
@@ -15,8 +14,6 @@ use crate::route::dhcp::get_dhcp_leases;
|
||||
use crate::route::status::get_status_json;
|
||||
use crate::route::wake::wake_multi;
|
||||
|
||||
use axum::Json;
|
||||
use axum::response::IntoResponse;
|
||||
use axum::routing::post;
|
||||
use axum::{Router, http::header, response::Html, routing::get};
|
||||
|
||||
@@ -60,13 +57,4 @@ pub fn api_router() -> Router {
|
||||
.route("/devs", get(devs_router))
|
||||
.route("/wake", post(wake_multi))
|
||||
.route("/ips/{name}", get(ip))
|
||||
.route(
|
||||
"/mac-cache",
|
||||
get(|| async {
|
||||
match load_mac_name_cache().await {
|
||||
Ok(h) => Json(h).into_response(),
|
||||
Err(e) => e.to_string().into_response(),
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -47,6 +47,14 @@ pub struct Filters {
|
||||
pub macs: Vec<MacAddr>,
|
||||
}
|
||||
|
||||
#[deprecated = "use ApiError"]
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Serialize, Default)]
|
||||
pub struct StatusError {
|
||||
pub name: Option<String>,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
pub async fn get_status_json(
|
||||
Query(DeviceQuery {
|
||||
name,
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ pub async fn _ping_ip_2<T: ToSocketAddrs>(_addr: T) -> bool {
|
||||
}
|
||||
|
||||
pub async fn _ping_ip_3<T: Into<IpAddr>>(addr: T) -> u8 {
|
||||
match get_mac(Some(addr.into()), None, &[] as &[NUDState]).await {
|
||||
match get_mac(Some(addr.into()), None, None).await {
|
||||
Err(_) => 0,
|
||||
Ok(l) => l
|
||||
.into_iter()
|
||||
|
||||
+13
-4
@@ -72,8 +72,13 @@ pub async fn get_macs(
|
||||
} else {
|
||||
devs.iter().next().map(AsRef::as_ref)
|
||||
};
|
||||
let opt_state = if state.len() > 1 {
|
||||
None
|
||||
} else {
|
||||
state.iter().next().copied()
|
||||
};
|
||||
|
||||
let run_one = |to_ip: Option<IpAddr>| get_mac(to_ip, opt_dev, state);
|
||||
let run_one = |to_ip: Option<IpAddr>| get_mac(to_ip, opt_dev, opt_state);
|
||||
|
||||
let mut ip_filtered = if let Some(something) = ip_all {
|
||||
if something.len() == 1 {
|
||||
@@ -92,6 +97,7 @@ pub async fn get_macs(
|
||||
// Apply additional filters if any were provided
|
||||
if !devs.is_empty() || !macs.is_empty() || !state.is_empty() {
|
||||
let devset: HashSet<_> = devs.iter().map(AsRef::as_ref).collect();
|
||||
let nudset: HashSet<_> = state.iter().collect();
|
||||
let macset: HashSet<_> = macs.iter().collect();
|
||||
|
||||
ip_filtered.retain(|entry| {
|
||||
@@ -99,10 +105,13 @@ pub async fn get_macs(
|
||||
let dev_ok =
|
||||
devset.is_empty() || entry.dev.as_deref().is_some_and(|d| devset.contains(d));
|
||||
|
||||
// NUD filter: always present, simple check
|
||||
let nud_ok = nudset.is_empty() || nudset.contains(&entry.state);
|
||||
|
||||
// MAC filter: if we're filtering by MAC, entry must have a MAC AND it must be in the set
|
||||
let mac_ok = macset.is_empty() || entry.mac.is_some_and(|m| macset.contains(&m));
|
||||
|
||||
dev_ok && mac_ok
|
||||
dev_ok && nud_ok && mac_ok
|
||||
})
|
||||
};
|
||||
Ok(ip_filtered)
|
||||
@@ -112,7 +121,7 @@ pub async fn get_macs(
|
||||
pub async fn get_mac(
|
||||
ip: Option<IpAddr>,
|
||||
dev: Option<&str>,
|
||||
state: &[NUDState],
|
||||
state: Option<NUDState>,
|
||||
) -> Result<Vec<IpNeighLine>> {
|
||||
let mut args: Vec<String> = vec!["neigh".into(), "show".into()];
|
||||
if let Some(ip) = ip {
|
||||
@@ -123,7 +132,7 @@ pub async fn get_mac(
|
||||
args.push("dev".into());
|
||||
args.push(d.to_string());
|
||||
}
|
||||
for nud in state {
|
||||
if let Some(nud) = state {
|
||||
args.push("nud".into());
|
||||
args.push(nud.as_ip_neigh_arg().into());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user