Jake Hillion
8fdb176f14
All checks were successful
continuous-integration/drone/push Build is passing
37 lines
801 B
Go
37 lines
801 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"`
|
|
|
|
Congestion string `validate:"required_unless=Method TCP,omitempty,oneof=NewReno None"`
|
|
|
|
KeepAlive uint
|
|
Timeout uint
|
|
RetryWait uint
|
|
}
|
|
|
|
func (c Configuration) Validate() error {
|
|
return v.Struct(c)
|
|
}
|