diff --git a/README.md b/README.md index 103be13..303c613 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,41 @@ -# Woly +# Wolz -Broadcast Wake on Lan (WoL) magic packet to network devices in the local network. +- Broadcast Wake on Lan (WoL) magic packet to network devices in the local network. +- WoL only works if the target network interface supports it and is not in low power mode. Check [arch wiki](https://wiki.archlinux.org/title/Wake-on-LAN) on this subject to setup your device to wakup -## Magic Packet +## Usage -If MAC = aa:bb:cc:dd:ee:ff +Run `wolz` to view the help text. -UDP packet is constructed as follows, and sent to 255.255.255.255:9 +## Troubleshooting -FF x 6; Mac Address x 16 +This tool broadcasts the magic packet to the limited broadcast address 255.255.255.255 and port 9. -eg. +Install `tcpdump` to inspect the network traffic published to the limited broadcast address (255.255.255.255) and port 9 + +```bash +$> # Update `enp42s0` to your interface name. +$> # To find out the interface to which the kernel +$> # routes the packets to, do +$> # ip route get 255.255.255.255 +$> sudo tcpdump -i enp42s0 udp and host 255.255.255.255 and port 9 -n -XX +$> +$> # Sample output for mac 04:7c:16:6e:c0:2f +0x0000: 4500 0082 6153 4000 4011 ceb6 0a60 0002 E...aS@.@....`.. +0x0010: ffff ffff 8bd0 0009 006e b739 ffff ffff .........n.9.... +0x0020: ffff 047c 166e c02f 047c 166e c02f 047c ...|.n./.|.n./.| +0x0030: 166e c02f 047c 166e c02f 047c 166e c02f .n./.|.n./.|.n./ +0x0040: 047c 166e c02f 047c 166e c02f 047c 166e .|.n./.|.n./.|.n +0x0050: c02f 047c 166e c02f 047c 166e c02f 047c ./.|.n./.|.n./.| +0x0060: 166e c02f 047c 166e c02f 047c 166e c02f .n./.|.n./.|.n./ +0x0070: 047c 166e c02f 047c 166e c02f 047c 166e .|.n./.|.n./.|.n +0x0080: c02f ./ ``` -FF FF FF FF FF FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF -AA BB CC DD EE FF + +If you have VPN enabled, depending on the configuration the kernel might route it to the tunnel interface, and the tool will not work. + +To debug TCP packets intended to wolz-daemon, run + +``` +$> sudo tcpdump -i lo tcp and port 21367 -n -XX ``` diff --git a/crates/wolz-client/src/main.rs b/crates/wolz-client/src/main.rs index 5686566..7dc6ee7 100644 --- a/crates/wolz-client/src/main.rs +++ b/crates/wolz-client/src/main.rs @@ -9,9 +9,17 @@ fn main() -> WResult<()> { return Ok(()); }; - let wolz = Wolz::create()?; - wolz.wake_up(&arg_1)?; - Ok(()) + match arg_1.as_str() { + "-h" | "--help" => { + print_usage(); + return Ok(()); + } + _ => { + let wolz = Wolz::create()?; + wolz.wake_up(&arg_1)?; + Ok(()) + } + } } fn print_usage() { @@ -20,20 +28,19 @@ fn print_usage() { r#"usage: woly ARG Options: - ARG Either the mac address of the device to send the wol magic - packet to, or a nickname specified in woly.conf to lookup - the mac. - Eg: woly aa:bb:cc:dd:ee:ff - Eg: woly potato - where potato is configured in the woly.conf file as - potato=aa:bb:cc:dd:ee:ff + ARG Either the mac address of the device to send the wol magic + packet to, or a nickname specified in woly.conf to lookup + the mac. See details about config file below. + Eg: woly aa:bb:cc:dd:ee:ff + Eg: woly potato Config file: Filename woly.conf Location $WOLY_CONFIG_DIR/woly.conf, then $XDG_CONFIG_DIR/woly.conf, then $HOME/woly.conf - Format one KEY=VALUE per line without spaces - Example potato=aa:bb:cc:dd:ee:ff + Format KEY=VALUE + one per line without spaces, no comments allowed + Example potato=aa:bb:cc:dd:ee:ff idly=12:34:23:e2:3d:ff "# ); diff --git a/crates/wolz-daemon/src/main.rs b/crates/wolz-daemon/src/main.rs index 593b2df..1bbd924 100644 --- a/crates/wolz-daemon/src/main.rs +++ b/crates/wolz-daemon/src/main.rs @@ -11,7 +11,7 @@ use std::{ fn main() -> DResult<()> { let address = "0.0.0.0:21367"; let listener = TcpListener::bind(address).map_err(DError::TcpBindError)?; - println!("Listening on {}", address); + println!("Listening for TCP packets at {}", address); for mut stream in listener.incoming() { match &mut stream { Ok(stream) => { diff --git a/crates/wolz-lib/src/config.rs b/crates/wolz-lib/src/config.rs index 756521d..f716af1 100644 --- a/crates/wolz-lib/src/config.rs +++ b/crates/wolz-lib/src/config.rs @@ -47,6 +47,7 @@ impl Config { &nick.name ))) .map(|mac| mac.clone()), + Device::IpV4(ip_v4) => todo!(), } } diff --git a/crates/wolz-lib/src/wolz.rs b/crates/wolz-lib/src/wolz.rs index b93c784..f20c7cc 100644 --- a/crates/wolz-lib/src/wolz.rs +++ b/crates/wolz-lib/src/wolz.rs @@ -30,7 +30,4 @@ impl Wolz { println!("Magic packet sent to 255.255.255.255:9 for Mac {:}", mac); Ok(()) } - - pub fn shutdown(&self, ip_or_nick: &str) -> WResult<()> { - } }