Implements Wake On Lan and management features (#164)

This commit is contained in:
ned3y2k 2022-03-20 18:03:27 +09:00 committed by GitHub
parent 037a6c56d3
commit 0224e1f137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 638 additions and 21 deletions

24
model/wake_on_lan_host.go Normal file
View file

@ -0,0 +1,24 @@
package model
import (
"errors"
"strings"
"time"
)
type WakeOnLanHost struct {
MacAddress string `json:"MacAddress"`
Name string `json:"Name"`
LatestUsed *time.Time `json:"LatestUsed"`
}
func (host WakeOnLanHost) ResolveResourceName() (string, error) {
resourceName := strings.Trim(host.MacAddress, " \t\r\n\000")
if len(resourceName) == 0 {
return "", errors.New("mac Address is Empty")
}
resourceName = strings.ToUpper(resourceName)
return strings.ReplaceAll(resourceName, ":", "-"), nil
}
const WakeOnLanHostCollectionName = "wake_on_lan_hosts"