Skip to content

guidohu/wakeonlan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wake-on-LAN Controller

A web-based Wake-on-LAN (WOL) application written in Go. It provides a beautiful, modern (glassmorphism) interface to manage and remotely power on your local network devices.

Features

  • Web-Based Management: Easily add, edit, View, and delete host entries using a responsive grid UI.
  • One-Click Wake: Send Magic Packets (WOL) instantly to wake up your configured devices.
  • Live Monitoring: Real-time visual ping status to check if a host is currently online.
  • Quick Access URLs: Provides clickable device names that link directly to a configurable access URL (e.g., your NAS interface or home server dashboard).
  • Master Monitoring Toggle: Conveniently enable or disable the ping monitoring status for all your devices at once.
  • Data Persistence: Stores your host configurations persistently in a simple hosts.json file.
  • Docker Ready: Fully containerized and ready to deploy via Docker and Docker Compose.

Tech Stack

  • Backend: Go (Golang) 1.22+
  • Frontend: HTML5, Vanilla JavaScript, CSS (Inter font, smooth gradients, and glassmorphic elements)
  • Deployment: Docker, Alpine Linux

Getting Started

Prerequisites

To run this application, you will need either:

  • Docker and Docker Compose
  • Go 1.22+ (if running locally without Docker)

Running via Docker Compose (Recommended)

This is the easiest way to deploy the application and ensures that your hosts.json file persists appropriately.

  1. Clone the repository:

    git clone <repo-url>
    cd wakeonlan
  2. Create a docker-compose.yml file with the following content:

    services:
      wakeonlan:
        build: .
        container_name: wakeonlan
        # Note: On Docker Desktop for Mac/Windows, UDP broadcasts may still not reach the physical LAN.
        # ports:
        #   - "127.0.0.1:8080:8080"
        network_mode: "host"
        environment:
          - PORT=8080
          - HOSTS_FILE=/data/hosts.json
          - ADMIN_USER=admin
          - ADMIN_PASSWORD=adminpassword
        volumes:
          - ./hosts.json:/data/hosts.json
        cap_add:
          - NET_ADMIN
          - NET_RAW
        restart: unless-stopped

    Why network_mode: "host" and cap_add?

    • Host Network (network_mode: "host"): Running the container on the host network is necessary so that Wake-on-LAN UDP broadcast packets can reach your physical local network. Without it, broadcasts are isolated to Docker's internal bridged network.
    • Network Capabilities (NET_ADMIN, NET_RAW): These capabilities grant the container elevated permissions to send raw network packets. This is required for the application's ICMP ping feature to successfully check if your devices are currently online.
  3. Start the container:

    docker compose up -d
  4. Access the web interface at: http://localhost:8080 (or your Docker host's IP address).

Note: On Docker Desktop for Mac or Windows, true host networking is not supported. You may need to uncomment the ports mapping to access the web interface, and UDP broadcasts might still not reach the physical LAN.

Running Locally (Development)

To run the application directly using Go without Docker:

  1. Clone the repository and navigate inside:
    git clone <repo-url>
    cd wakeonlan
  2. Run the application:
    go run main.go
  3. Access the web interface at: http://localhost:8080

Configuration

You can configure the application using environment variables:

  • PORT: Sets the port for the web server (Default: 8080).
  • HOSTS_FILE: Absolute or relative path to the persistent JSON file storing the hosts (Default: hosts.json locally or /data/hosts.json inside the Docker container).
  • ADMIN_USER: The username for the web interface login (Default: admin).
  • ADMIN_PASSWORD: The password for the web interface login (Default: admin).
  • JWT_SECRET: A custom secret key to sign JWT tokens. If not provided, a secure random key is generated on startup.

Managing Hosts

When you click the + (Add Host) button in the UI, you can provide the following information:

  • Name (Required): Label to identify your device.
  • MAC Address (Required): The MAC address of the device to wake up (e.g., 00:11:22:33:44:55).
  • Broadcast IP (Optional): Provide your specific network broadcast IP instead of the default global broadcast (255.255.255.255).
  • Host IP (Optional): Highly recommended for live monitoring. Used by the ping feature to track the device's online status.
  • Access URL (Optional): Transform your device's name into a clickable link to an admin panel or specific service URL.
  • Enable Monitoring: Toggle ping monitoring locally for each device.

API Endpoints

The Go backend serves a simple REST API on /api/hosts.

  • POST /api/login - Authenticate and receive a JWT token.
  • GET /api/hosts - Retrieve all host records.
  • POST /api/hosts - Create a new host record.
  • PUT /api/hosts/:id - Edit an existing host record.
  • DELETE /api/hosts/:id - Delete a given host record.
  • POST /api/hosts/:id/wake - Send a Wake-on-LAN Magic Packet to the host.
  • GET /api/hosts/:id/ping - Ping the particular host.

License

MIT

About

Simple application that let's you send wake-on-lan to your devices using a UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors