This commit is contained in:
lda
2025-12-16 17:49:36 +07:00 Unverified
parent 73278074c5
commit c5c7fd8cca
4 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ try {
if (Test-Path $localStatic) { if (Test-Path $localStatic) {
# Assuming RemotePath is like /root/.bin/wakey, we want /root/.bin/static # Assuming RemotePath is like /root/.bin/wakey, we want /root/.bin/static
# So we push 'static' directory to /root/.bin/ # So we push 'static' directory to /root/.bin/
$remoteDir = Split-Path $RemotePath -Parent $remoteDir = (Split-Path $RemotePath -Parent) -replace '\\', '/'
# Ensure remote dir exists (ssh mkdir -p) # Ensure remote dir exists (ssh mkdir -p)
Invoke-Ssh -Cmd "mkdir -p $remoteDir" -User $User -Remote $HostName -Pass $Pass -Quiet:$Quiet Invoke-Ssh -Cmd "mkdir -p $remoteDir" -User $User -Remote $HostName -Pass $Pass -Quiet:$Quiet
+9 -5
View File
@@ -8,14 +8,14 @@
//! 2. incorporate ip -j; //! 2. incorporate ip -j;
//! 3. small 1-5 second caching; //! 3. small 1-5 second caching;
use axum::{Router, routing::get}; use axum::Router;
use tokio::net::TcpListener; use tokio::net::TcpListener;
mod arpparse; mod arpparse;
pub mod assets; pub mod assets;
mod dhcpparse; mod dhcpparse;
mod route; mod route;
mod utils; mod utils;
use std::io; use std::{env, io};
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[tokio::main] #[tokio::main]
@@ -23,14 +23,18 @@ async fn entry() -> io::Result<()> {
use crate::route::api_router; use crate::route::api_router;
use axum::routing::get_service; use axum::routing::get_service;
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
let exe = env::current_exe()?;
let root = exe
.parent()
.ok_or_else(|| io::Error::other("no parent dir"))?;
let static_dir = ServeDir::new(root.join("static"));
let app = Router::new() let app = Router::new()
// .route("/home", get(home)) // .route("/home", get(home))
// .route("/", get(home_2)) // .route("/", get(home_2))
// .merge(home_2_route()) // .merge(home_2_route())
.nest_service("/", get_service(ServeDir::new("static")))
// .route("/status", get(get_status_2)) // .route("/status", get(get_status_2))
.nest("/api", api_router()); .nest("/api", api_router())
.fallback_service(get_service(static_dir));
let port = TcpListener::bind("0.0.0.0:12012").await?; let port = TcpListener::bind("0.0.0.0:12012").await?;
axum::serve(port, app.into_make_service()).await?; axum::serve(port, app.into_make_service()).await?;
+1 -1
View File
@@ -39,7 +39,7 @@ pub fn home_2_route() -> Router {
"/home_2/styles.css", "/home_2/styles.css",
get(|| async { get(|| async {
( (
[ [
(header::CONTENT_TYPE, "text/css; charset=utf-8"), (header::CONTENT_TYPE, "text/css; charset=utf-8"),
(header::CACHE_CONTROL, "public, max-age=300"), (header::CACHE_CONTROL, "public, max-age=300"),
], ],
+1 -1
View File
@@ -4,4 +4,4 @@ pub mod macs;
pub mod parser; pub mod parser;
pub use leases::*; pub use leases::*;
pub use macs::*; pub use macs::*;