46 lines
656 B
Go
46 lines
656 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"github.com/BurntSushi/toml"
|
||
|
)
|
||
|
|
||
|
type httpFeature struct {
|
||
|
Host string
|
||
|
Port int
|
||
|
}
|
||
|
|
||
|
type sshFeature struct {
|
||
|
SSHKeyPath string
|
||
|
SSHKeyPassphrasePath string
|
||
|
}
|
||
|
|
||
|
type wolTarget struct {
|
||
|
Name string
|
||
|
MAC string
|
||
|
}
|
||
|
|
||
|
type limitsFeature struct {
|
||
|
RemoteCmds []string
|
||
|
WolHosts []wolTarget
|
||
|
}
|
||
|
|
||
|
type tomlConfig struct {
|
||
|
HTTP httpFeature `toml:"http"`
|
||
|
SSH sshFeature `toml:"ssh"`
|
||
|
Limits limitsFeature `toml:"limits"`
|
||
|
}
|
||
|
|
||
|
func readConfig(path string) *tomlConfig {
|
||
|
var conf tomlConfig
|
||
|
_, err := toml.DecodeFile(path, &conf)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
// log.Println(meta.Keys())
|
||
|
|
||
|
return &conf
|
||
|
}
|