dissertation-2-code/config/config.go
2020-10-23 20:07:15 +01:00

28 lines
553 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"`
Methods []string `validate:"min=1,dive,oneof=TCP"`
}
type Peer struct {
PublicKey string `validate:"required"`
Method string `validate:"oneof=TCP"`
RemoteHost string `validate:"required,fqdn|ip"`
RemotePort uint `validate:"required,max=65535"`
}
func (c Configuration) Validate() error {
return v.Struct(c)
}