diff --git a/Cargo.lock b/Cargo.lock index ab519e0..4f96cad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,6 +1336,12 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "wake-on-lan" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ccf60b60ad7e5b1b37372c5134cbcab4db0706c231d212e0c643a077462bc8f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1569,6 +1575,7 @@ dependencies = [ "ping-rs", "pulldown-cmark", "serde", + "wake-on-lan", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0a1297f..ed2adaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ actix-files = "0.6" pulldown-cmark = "0.9" # Markdown parser ping-rs = "0.1.2" serde = { version = "1.0", features = ["derive"] } +wake-on-lan = "0.2.0" diff --git a/src/main.rs b/src/main.rs index 4e39468..68e5ecf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use actix_web::{web, App, HttpServer, HttpResponse, Responder}; use std::fs; use std::time::Duration; use serde::Deserialize; +use wake_on_lan; #[derive(Deserialize)] struct WakeQuery { @@ -116,7 +117,14 @@ async fn wake(query: web::Query) -> impl Responder { let password = &query.password; if password == "magic" { + let mac_address: [u8; 6] = [0xC0, 0x7C, 0xD1, 0xFB, 0xC9, 0x86]; + + let magic_packet = wake_on_lan::MagicPacket::new(&mac_address); + + let _ = magic_packet.send(); + serve_markdown("pages/summary.md", Some(true)).await + } else { serve_markdown("pages/summary.md", Some(false)).await }