From ca310b18ec187db8df4e0b14bfd51ca7f8fb4e7a Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Tue, 3 Mar 2020 21:06:36 +0000 Subject: [PATCH] update report types with config changes --- reporttypes.go | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/reporttypes.go b/reporttypes.go index 4edc62f..5c0295d 100644 --- a/reporttypes.go +++ b/reporttypes.go @@ -3,36 +3,43 @@ package dsnet import ( "net" "time" - - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) type DsnetReport struct { - Name string - PrivateKey wgtypes.Key - PublicKey wgtypes.Key - ListenPort int - Peers []PeerReport + // domain to append to hostnames. Relies on separate DNS server for + // resolution. Informational only. + ExternalIP net.IP `validate:"required,cidr"` + ListenPort int `validate:"gte=1024,lte=65535"` + Domain string `validate:"required,gte=1,lte=255"` + // IP network from which to allocate automatic sequential addresses + // Network is chosen randomly when not specified + Network JSONIPNet `validate:"required"` + IP net.IP `validate:"required,cidr"` + DNS net.IP `validate:"required,cidr"` + Peers []PeerReport } type PeerReport struct { - // username of person running this host/router - Owner string // Used to update DNS - Hostname string + Hostname string `validate:"required,gte=1,lte=255"` + // username of person running this host/router + Owner string `validate:"required,gte=1,lte=255"` // Description of what the host is and/or does - Description string + Description string `validate:"required,gte=1,lte=255"` + // Internal VPN IP address. Added to AllowedIPs in server config as a /32 + IP net.IP `validate:"required,ip` + PublicKey JSONKey `validate:"required,len=44"` + PrivateKey JSONKey `json:"-"` // omitted from config! + PresharedKey JSONKey `validate:"required,len=44"` // whether last heartbeat/rxdata was received (50% margin) Online bool // if no data for x days, consider revoking access Expired bool - - PublicKey wgtypes.Key - PresharedKey wgtypes.Key - // TODO peer endpoint support - //Endpoint *net.UDPAddr + // TODO ExternalIP support (Endpoint) + //ExternalIP net.UDPAddr `validate:"required,udp4_addr"` + // TODO support routing additional networks (AllowedIPs) + Networks []JSONIPNet `validate:"dive,cidr"` LastHandshakeTime time.Time ReceiveBytes int64 TransmitBytes int64 - AllowedIPs []net.IPNet }