https://github.com/ahmetozer/wakeonlan
Golang wake on lan service
https://github.com/ahmetozer/wakeonlan
api go golang ipv4 ipv6 linux wake-on-lan wakeonlan wol
Last synced: about 1 year ago
JSON representation
Golang wake on lan service
- Host: GitHub
- URL: https://github.com/ahmetozer/wakeonlan
- Owner: ahmetozer
- Created: 2022-02-13T21:52:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-26T09:38:53.000Z (about 4 years ago)
- Last Synced: 2025-04-14T07:47:00.833Z (about 1 year ago)
- Topics: api, go, golang, ipv4, ipv6, linux, wake-on-lan, wakeonlan, wol
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Wake On Lan Service
This application is implemented with golang to wake up the computers.
## Service Configration
By default, http server listens `:8080` address.
To change or bind different address, set *`LISTEN`* environment variable.
## Container
```bash
docker run -it --rm --network host ghcr.io/ahmetozer/wakeonlan
```
## Available API endpoints
You wake up the computers via web ui or if you want you can
use api endpoints.
### Interfaces
List the interfaces with IP addresses.
- Method: *`GET`*
- Endpoint: `/api/interfaces`
```json
[
{
"Device": "lo",
"IPAddr": [
"127.0.0.1/8",
"::1/128"
]
}
]
```
### ArpEntries
List the MAC addreses with details.
- Method: *`GET`*
- Endpoint: `/api/arpentries`
```json
[
{
"IPAddr": "172.23.80.1",
"HWType": "0x1",
"Flags": "0x2",
"HWAddr": "00:15:5d:f5:bd:67",
"Mask": "*",
"Device": "eth0"
}
]
```
### WakeOnLan
To wake up the computers.
- Method: *`POST`*
- Endpoint: `/api/wakeonlan`
Example request body
```json
[
{
"mac": "00:15:5d:f5:bd:67",
"if": "lo",
"addr": "255.255.255.255",
"port": "7"
},
{
"mac": "00:15:5d:f5:bd:67",
"if": "eth0",
"addr": "fe80::900d:cafe:900d:c0de",
"port": "7"
},
{
"mac": "00:15:5d:f5:bd:67",
"if": "eth0",
"addr": "2001:db8:900d:cafe:900d:c0de:900d:11fe",
"port": "7"
}
]
```
Server respond
```json
[
{
"RequestNo": 1,
"Status": "packet send"
}
]
```
## Usage of package
You can use wake on lan as golang function
```go
package main
import (
wakeonlan "github.com/ahmetozer/wakeonlan/share"
)
func main() {
mac, _ := net.ParseMAC("00:15:5d:f5:bd:67")
packet := wakeonlan.MagicPacket{HWAddr: mac, Device: "eth0", IPAddr: "255.255.255.255", Port: "7"}
err := packet.SendMagicPacket()
if err != nil {
fmt.Printf("%v", err)
}
}
```