dissertation-2-code/config/config.go

35 lines
712 B
Go
Raw Normal View History

2020-10-23 20:07:15 +01:00
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 {
2020-11-02 17:24:15 +00:00
PrivateKey string `validate:"required"`
InterfaceName string
2020-10-23 20:07:15 +01:00
}
type Peer struct {
PublicKey string `validate:"required"`
2020-11-26 19:18:07 +00:00
Method string `validate:"oneof=TCP UDP"`
2020-10-23 20:07:15 +01:00
2020-10-24 17:44:14 +01:00
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
2020-10-23 20:07:15 +01:00
}
func (c Configuration) Validate() error {
return v.Struct(c)
}