dissertation-2-code/config/config.go
Jake Hillion 787f80dc90
Some checks failed
continuous-integration/drone/push Build is failing
validation and logging improvements
2020-11-26 19:18:07 +00:00

35 lines
712 B
Go

package config
import "github.com/go-playground/validator/v10"
var v = validator.New()
type Configuration struct {
Host Host
Peers []Peer `validate:"dive"`
}
type Host struct {
PrivateKey string `validate:"required"`
InterfaceName string
}
type Peer struct {
PublicKey string `validate:"required"`
Method string `validate:"oneof=TCP UDP"`
LocalHost string `validate:"omitempty,ip"`
LocalPort uint `validate:"max=65535"`
RemoteHost string `validate:"required_with=RemotePort,omitempty,fqdn|ip"`
RemotePort uint `validate:"required_with=RemoteHost,omitempty,max=65535"`
KeepAlive uint
Timeout uint
RetryWait uint
}
func (c Configuration) Validate() error {
return v.Struct(c)
}