diff --git a/README.md b/README.md index 79f9bd1..9a7987a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a daemon which listens for wake-on-LAN ("WOL") packets, and upon spottin One use-case (my use case) is to have a gaming VM that doesn't need to be running all the time. NVIDIA Gamestream and Moonlight both have the ability to send WOL packets in an attempt to wake an associated system. For "real" hardware, this works great. Unfortunately, for VMs it doesn't really do anything since there's no physical NIC snooping for the WOL packet. This daemon attempts to solve that. ## Mechanics -When started, this daemon will use `libpcap` to make a listener on the specified network interface, listening for packets that look like they might be wake-on-lan. Due to how `pcap` works, the current filter is for UDP sent to the broadcast address with a length of 144 bytes. This seems to generate very low false-positives, doesn't require the NIC to be in promiscuous mode, and overall seems like a decent filter. +When started, this daemon will use `libpcap` to make a listener on the specified network interface, listening for packets that look like they might be wake-on-lan. Due to how `pcap` works, the current filter is for UDP sent to the broadcast address with a length of 234 bytes (the size of a WOL packet w/security). This seems to generate very low false-positives, doesn't require the NIC to be in promiscuous mode, and overall seems like a decent filter. Upon receipt of a (probable) WOL packet, the daemon extracts the first MAC address (WOL packets are supposed to repeat the target machine MAC a few times). @@ -20,5 +20,14 @@ The daemon will keep running until killed with a SIGINT (`^c`). Because this daemon, and wake-on-LAN, operate by MAC addresses, any VMs that are a candidate to be woken must have a hard-coded MAC in their machine configuration. -## systemd example service -There's a systemd service template example in virtwold@.service that should make it easy to configure for any interfaces that you need to run on +## System Integration + +### systemd example service +There's a systemd service template example in `init-scripts/virtwold@.service` that should make it easy to configure for any interfaces that you need to run on + +## OpenRC example init script +Systems which use openrc can find an example init script and associated conf file in `init-scripts/openrc`. The interface should be adjusted to match your particular needs (e.g., swap `eth0` for `enp44s0` or something like that). + +## Gentoo ebuild +An ebuild for Gentoo systems is available in [here](https://github.com/ScottESanDiego/scotterepo/tree/main/app-emulation/virtwold), although it only installs OpenRC init files (since that's what I use). + diff --git a/init-scripts/openrc/virtwold.confd b/init-scripts/openrc/virtwold.confd new file mode 100644 index 0000000..695f098 --- /dev/null +++ b/init-scripts/openrc/virtwold.confd @@ -0,0 +1,4 @@ +# /etc/conf.d/virtwold +# +# Specify the interface to be used +VIRTWOLD_INTERFACE="eth0" diff --git a/init-scripts/openrc/virtwold.initd b/init-scripts/openrc/virtwold.initd new file mode 100644 index 0000000..769382c --- /dev/null +++ b/init-scripts/openrc/virtwold.initd @@ -0,0 +1,31 @@ +#!/sbin/openrc-run +# Copyright 2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +name="virtwold daemon" +description="Virtual Wake-on-LAN Daemon" +command=/usr/bin/virtwold +command_args="--interface ${VIRTWOLD_INTERFACE}" + +PIDFILE=/run/virtwold.pid + +depend() { + need net +} + +start() { + start-stop-daemon \ + --start \ + --exec ${command} \ + --background \ + --stdout-logger /usr/bin/logger \ + --make-pidfile \ + --pidfile "${PIDFILE}" \ + -- ${command_args} +} + +stop() { + start-stop-daemon \ + --stop \ + --pidfile "${PIDFILE}" +} diff --git a/virtwold@.service b/init-scripts/systemd/virtwold@.service similarity index 100% rename from virtwold@.service rename to init-scripts/systemd/virtwold@.service