From 9a214d89872b403ff6d8dd368829d24714a4397c Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Mon, 2 Mar 2020 19:38:00 +0000 Subject: [PATCH] fix net JSON parsing --- types.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types.go b/types.go index 587a779..b6f78ce 100644 --- a/types.go +++ b/types.go @@ -12,10 +12,10 @@ import ( // see https://github.com/WireGuard/wgctrl-go/blob/master/wgtypes/types.go for definitions type PeerConfig struct { - // username of person running this host/router - Owner string `validate:"required,gte=1,lte=255"` // Used to update DNS 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 `validate:"required,gte=1,lte=255"` @@ -152,7 +152,8 @@ func (n JSONIPNet) MarshalJSON() ([]byte, error) { func (n *JSONIPNet) UnmarshalJSON(b []byte) error { cidr := strings.Trim(string(b), "\"") - _, IPNet, err := net.ParseCIDR(cidr) + IP, IPNet, err := net.ParseCIDR(cidr) + IPNet.IP = IP n.IPNet = *IPNet return err }