A self-contained, single-binary Rust and Leptos application for remote Wake-on-LAN

Related tags

Utilities rust wol leptos
Overview

Remote Wake-on-LAN with Rust and Leptos

Build Docker

A self-contained, single-binary Rust and Leptos application serving a web interface to wake another device on the network through its ethernet adapter using Wake-on-LAN magic packets.

a screenshot of the web-app

A utility to wake up a local computer remotely using a web interface.

Usage: remote_wol [OPTIONS]

Options:
  -m, --mac <MAC_ADDRESS>  The MAC address of the device to wake up
  -i, --ip <IP_ADDRESS>    The IP of the device to wake up (for monitoring)
  -p, --pass <PASSPHRASE>  The passphrase to use to wake up the device
      --port <PORT>        The local port used to serve the web app [default: 3000]
      --host               Expose the web app to the local network
  -h, --help               Print help
  -V, --version            Print version

Quick start

The binary expects at least 2 arguments:

  • the MAC address of the device to wake up
  • the passphrase that will protect this interface from unauthorized use
  • (optional) the local IP address of the device to wake up, for monitoring its upstate.
  • (optional) the port where the web interface will be served (default: 3000)
  • (optional) whether to run the interface on 0.0.0.0 (accessible on the local network) or 127.0.0.1 (only on the loopback interface)
remote_wol -m 01:02:03:04:05:06 -p your_l0ng_but_easy_to_remember_passphrase -i 192.168.0.123

Alternatively, those parameters can be provided with environment variables, even using a .env file in the same directory:

  • WOL_MAC_ADDRESS
  • WOL_PASSPHRASE
  • WOL_IP_ADDRESS
  • WOL_PORT
  • WOL_HOST: e.g. 0.0.0.0 (expose to local network) or 127.0.0.1 (only on the loopback interface)

About permissions

In order for this binary to ping the target device, special permissions are required on linux and macOS.

For linux, you can add (once) the cap_net_raw capability flag to the binary (requires root) and then use it later in user space.

sudo setcap 'cap_net_raw+epi' ./remote_wol
# new session, can be used as user
./remote_wol [OPTIONS]

For macOS, you probably need to run the binary as root to enable the ping to work:

sudo ./remote_wol [OPTIONS]

On Windows, ping should work out of the box.

Using Docker

The application is available as a docker image.

docker run --network="host" -d vbersier/remote-wol-rs:latest -m 01:02:03:04:05:06 \
-p your_l0ng_but_easy_to_remember_passphrase -i 192.168.0.123

Example using docker-compose

services:
  wol:
    image: vbersier/remote-wol-rs:latest
    restart: unless-stopped
    # host mode is needed for UDP broadcast
    network_mode: host
    environment:
      WOL_IP_ADDRESS: '192.168.0.123'
      WOL_MAC_ADDRESS: 01:02:03:04:05:06
      WOL_PASSPHRASE: your_l0ng_but_easy_to_remember_passphrase

Accessing from the internet

This web interface is not automatically accessible through the internet. You could, for instance, forward port 3000 in your firewall to the device running remote-wol-rs, and then accessing it through its public IP.

You could also use a dynDNS service to have a domain name always pointing to your device's public IP.

Finally, you could use something like Cloudflare Tunnel to setup a permanent tunnel to your local webserver through a custom domain.

Building from source

To build your own executable, you need to install the rust nightly toolchain and wasm32-unknown-unknown target:

rustup toolchain install nightly
rustup +nightly target add wasm32-unknown-unknown

As a pre-build step, you need to compile the CSS using tailwindcss:

tailwindcss -i style/input.css -o style/output.css --minify

Then, you probably should use the cargo-leptos utility:

cargo install cargo-leptos
cargo leptos build --release

Finally, in order for the resulting self-contained binary (target/server/release/remote_wol) to be able to send ping requests, you need to either run it as root, or if you system supports capabilitity flags, to add the cap_net_raw capability like below:

sudo setcap 'cap_net_raw+epi' ./target/server/release/remote_wol

Credits

This application relies heavily on wol-rs and Leptos for its core functionality. Thank you to their respective authors and maintainers!

You might also like...
Incremental, multi-version remote backup tool for block devices.

bsync Incremental, multi-version remote backup tool for block devices. The on-disk backup format is a SQLite database and I've been dogfooding this on

The system for remote workers to prevent their family members from interrupting conference calls
The system for remote workers to prevent their family members from interrupting conference calls

onair The system for remote workers to prevent their family members from interrupting conference calls. The system is designed to automatically detect

A Self-Reference Helper For Rust.

Self-Reference A Self-Refernece Helper (Inspired From Selfie) this crate provides safe access to its self-reference. the main idea is not initializing

Octopus Linguistics for self-hosted runners

octoling Octopus Linguistics for self-hosted runners. Early PoC Allows to create self-hosted ephemeral runners on various providers. (currently only s

Self-Hosted alternative to GitHub Gists

Gists Self-Hosted GitHub Gists Features Upload code snippets Syntax Highlighting Comments Versioning through Git Fork gists Gist privacy: public, unli

Manage self-hosted Supabase instances with an easy to use API & Web Portal (soon)

SupaManager A project by Harry Bairstow; Manage self-hosted Supabase instances with an easy to use API & Web Portal (soon) ⚠️ Note: The project is in

Rust library to scan files and expand multi-file crates source code as a single tree

syn-file-expand This library allows you to load full source code of multi-file crates into a single syn::File. Features: Based on syn crate. Handling

single file, std only, async Rust executor

whorl - A single file, std only, async Rust executor whorl was created to teach you how async executors work in Rust. It is not the fastest executor n

An opinionated Rust library for interacting with AWS DynamoDB single-table designs.

Modyne An opinionated library for interacting with AWS DynamoDB single-table designs. † Motive Modyne follows the precepts laid out for effective sing

Comments
  • Pre-compile CSS

    Pre-compile CSS

    Compiling CSS sometimes treeshakes too many classes, and when it happens in CI there is no recourse. Thus CSS will be manually compiled and checked into the repo.

    opened by beeb 0
Releases(v0.2.4)
Owner
Valentin Bersier
Valentin Bersier
Tauri and Leptos example.

tauri-leptos-example Tauri Leptos Requires Rust Nightly. See Leptos nightly Note. # Install Tauri CLI cargo install tauri-cli # Build and develop for

Michal Vavra 5 Dec 6, 2022
Build tool for Leptos (Rust)

Build tool for Leptos: Features Getting started Single-package setup Workspace setup Build features Parameters reference Compilation parameters Site p

henrik 39 Jan 5, 2023
📮 load, write, and copy remote and local assets

axoasset This library offers read, write, and copy functions, for local and remote assets given a string that contains a relative or absolute local pa

axo 7 Jan 25, 2023
Remoc 🦑 — Remote multiplexed objects and channels for Rust

Remoc ?? — remote multiplexed objects and channels Remoc makes remote interaction between Rust programs seamless and smooth. Over a single underlying

ENQT GmbH 98 Dec 21, 2022
Mobile safari / webview remote debugging and e2e testing libraries

Canter (WIP) (WIP) Mobile safari / webview remote debugging and e2e testing libraries. Developed for safari/webview e2e testing on iPhone. Works only

Han Lee 9 Aug 16, 2022
A stupidly simple and easy to self-host, personal server for file hosting on the web

Grasswave CDN A stupidly simple and easy to self-host, personal server for file hosting on the web. Written in Rust. Thanks, @Maciejowski, for the sty

Rafał Baran 3 Jan 3, 2023
Twidge is a fresh approach to productivity. It integrates with your workflow and allows you to be your most productive self.

Twidge A productivity app which is an extension to your mind Twidge is a cross platform productivity app, powered by rust, tauri, prisma-client-rust T

Twidge 187 Jun 28, 2023
M8 remote display - Rust

RM8 Remote display for the Dirtywave M8 I first tried M8WebDisplay then discovered m8c and decided to use it as a starting point for my own version in

Alex Boussinet 30 Dec 31, 2022
🌲 Open the current remote repository in your browser

gitweb Some of the flags and options are subject to change in the future. Ideas are welcome. Ideas are bulletproof (V). gitweb is a command line inter

Yoann Fleury 26 Dec 17, 2022
Remote Secret Editor for AWS Secret Manager

Barberousse - Remote Secrets Editor About Usage Options Printing Editing Copying RoadMap 1.0 1.1 Future About A project aimed to avoid downloading sec

Mohamed Zenadi 18 Sep 28, 2021