Categorygithub.com/mordredp/wololo
modulepackage
0.0.0-20230723155134-9f96c376caa7
Repository: https://github.com/mordredp/wololo.git
Documentation: pkg.go.dev

# README

made-with-Go proc-arch os

Web interface for sending Wake-on-lan (magic packet)

Based on Samer Dhoot's project https://github.com/sameerdhoot/wolweb.

A GoLang based HTTP server which will send a Wake-on-lan package (magic packet) on local network. The request can be send using web interface or directly using an HTTP request with the mapped device name in the URL.

I needed the webserver to support binding to a specific IP for usage with a reverse proxy. I also plan to add LDAP support for access to the web interface and API.

Bootstrap UI with JS Grid for editing data

Screenshot

The UI features CRUD operation implemented using js-grid.com plugin.

Wake-up directly using HTTP Request

/wolweb/wake/<hostname> - Returns a JSON object

{
  "success":true,
  "message":"...",
  "error":null
}

Configure the app

The application will use the following default values if they are not explicitly configured as explained in sections below.

ConfigDescriptionDefault
ListenIPDefine the IP on which the webserver will listen0.0.0.0
PortDefine the port on which the webserver will listen8089
Broadcast IP and PortThis is broadcast IP address and port for the local network. Please include the port :9192.168.1.255:9

You can override the default application configuration by using a config file or by setting environment variables. The application will first load values from config file and look for environment variables and overwrites values from the file with the values which were found in the environment.

Using config.json:

{
    "ip": "0.0.0.0",
    "port": 8089,
    "bcastip":"192.168.1.255:9"
}

Using Environment Variables:

Environment variables takes precedence over values in config.json file.

Variable NameDescription
WOLOLOIPOverride for default HTTP listening IP
WOLOLOPORTOverride for default HTTP port
WOLOLOBCASTIPOverride for broadcast IP address and port

Devices (targets) - devices.json format

{
    "devices": [
        {
            "name": "Server",
            "mac": "34:E6:D7:33:12:71",
            "ip": "192.168.1.255:9"
        },
        {
            "name": "NAS",
            "mac": "28:C6:8E:36:DC:38",
            "ip": "192.168.1.255:9"
        },
        {
            "name": "Laptop",
            "mac": "18:1D:EA:70:A0:21",
            "ip": "192.168.1.255:9"
        }
    ]
}

Usage with Docker

This project includes Dockerfile (based on Alpine) and docker-compose.yml files which you can use to build the image for your platform and run it using the docker compose file. The Dockerfile is tested to build an image on a Raspberry Pi. If you want to use this application as-is, you will only need to download these two docker-related files to get started. The docker file will grab the code and compile it for your platform.

I could not get this to run using Docker's bridged network. The only way I was able to make it work was to use host network for the docker container. See this https://github.com/docker/for-linux/issues/637 for details.

With docker-compose

docker-compose up -d

Build and run manually

docker build -t wololo .
docker run --network host -it wololo

Extract the compiled application from an image

docker cp wololo:/wololo - > wololo.gz

Build on Windows

I use VS Code with Go extension. To build this project on Windows:

go build -o wololo.exe .

Credits

Thank you you to Sameer Dhoot's project https://github.com/sameerdhoot/wolweb for providing the framework which I modified a little to work within constraints of environment.

Thank you to David Baumann's project https://github.com/dabondi/go-rest-wol for providing the framework which I modified a little to work within constraints of environment.

# Functions

GetIPFromInterface function get IP Address of interface.
NewMagicPacket function accepts a MAC Address string, and returns a pointer to a MagicPacket object.
SendMagicPacket to send a magic packet to a given mac address, and optionally receives an iface to broadcast on.

# Structs

Config represents a configuration object to initialize this application.
Data is list of Computer objects defined in JSON config file.
Device represents a Host to be woken up.
A MagicPacket is constituted of 6 bytes of 0xFF followed by 16 groups of the destination MAC address.
Response represents the API response.

# Type aliases

MACAddress define construct for MAC Address.
No description provided by the author