Giter Club home page Giter Club logo

wakeup's Introduction

wakeup

Build Status

wakeup provides a small HTTP API and JavaScript front-end for sending Wake-on-LAN messages to a target device.

Devices

Devices and their MAC addresses are stored in a file called wakeup-cache. An example is included in this repo. You can persist any changes in the Devices list by mounting this file as a Volume when you start the container.

Running wakeup with docker-compose

docker-compose up -d

wakeup usage

$ wakeup -h
Usage:
  wakeup [OPTIONS]

Application Options:
  -c, --cache=FILE     Path to cache file
  -b, --bind=IP        IP address to bind to when sending WOL packets
  -l, --listen=ADDR    Listen address (default: :8080)
  -s, --static=DIR     Path to directory containing static assets

Help Options:
  -h, --help           Show this help message

wakeupbr usage

$ wakeupbr -h
Usage:
  wakeupbr [OPTIONS]

Application Options:
  -l, --listen=IP     Listen address to use when listening for WOL packets (default: 0.0.0.0:9)
  -o, --forward=IP    Address of interface where received WOL packets should be forwarded

Help Options:
  -h, --help          Show this help message

API

Wake a device:

$ curl -XPOST -d '{"macAddress":"AB:CD:EF:12:34:56"}' http://localhost:8080/api/v1/wake

A name for the device can also be provided, to make it easy to identify later:

$ curl -XPOST -d '{"name":"foo","macAddress":"AB:CD:EF:12:34:56"}' http://localhost:8080/api/v1/wake

List devices that have previously been woken:

$ curl -s http://localhost:8080/api/v1/wake | jq .
{
  "devices": [
    {
      "name": "foo",
      "macAddress": "AB:CD:EF:12:34:56"
    }
  ]
}

Delete a device:

$ curl -XDELETE -d '{"macAddress":"AB:CD:EF:12:34:56"}' http://localhost:8080/api/v1/wake

Front-end

A basic JavaScript front-end is included. It can be served by wakeup by passing the path to static as the -s option.

Front-end screenshot

Bridge

The wakeupbr program acts as bridge for Wake-on-LAN packets. The program listens for Wake-on-LAN packets on the incoming interface and forwards any received packets to the outgoing interface.

Example:

A device has two interfaces, one wired (eth0) with the address 172.16.0.10 and one wireless (wlan0) with the address 10.0.0.10. The device we want to wake is on the wired network. We want to pick up Wake-on-LAN packets that are received on the wireless network and send them out on the wired network. This can be accomplished with the following command:

$ wakeupbr -l 10.0.0.10 -o 172.16.0.10

Any Wake-on-LAN packet that is broadcast on the wireless network will then be forwarded. When a packet is received and forwarded, a message will be logged:

2017/07/28 19:34:54 Forwarded magic packet for AA:BB:CC:12:34:56 to 172.16.0.10

The command above listens on UDP port 9 for Wake-on-LAN packets. As port 9 is a privileged port, wakeupbr must be run as root. This is less than ideal, but Wake-on-LAN packets are always broadcast to port 9. To avoid binding to a privileged port we can use a iptables rule:

$ iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 9 -j REDIRECT --to-port 9000

You should also ensure that traffic to UDP port 9000 is accepted by the INPUT chain:

$ iptables -A INPUT -p udp --dport 9000 -j ACCEPT

This will redirect all packets on UDP port 9 to port 9000. wakeupbr can then listen on port 9000 and run as a regular user:

$ wakeupbr -l 10.0.0.10:9000 -o 172.16.0.10

wakeup's People

Contributors

mpolden avatar jornack avatar anjia0532 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.