fix parsing -- needed a pointer method

This commit is contained in:
Callan Bryant 2020-03-02 02:49:44 +00:00
parent 11a4ab4fc0
commit 9c470d4534
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA

View File

@ -74,7 +74,7 @@ func (n JSONIPNet) MarshalJSON() ([]byte, error) {
return []byte("\"" + n.IPNet.String() + "\""), nil
}
func (n JSONIPNet) UnmarshalJSON(b []byte) error {
func (n *JSONIPNet) UnmarshalJSON(b []byte) error {
cidr := strings.Trim(string(b), "\"")
_, IPNet, err := net.ParseCIDR(cidr)
n.IPNet = *IPNet
@ -93,7 +93,7 @@ func (k JSONKey) MarshalJSON() ([]byte, error) {
return []byte("\"" + k.Key.String() + "\""), nil
}
func (k JSONKey) UnmarshalJSON(b []byte) error {
func (k *JSONKey) UnmarshalJSON(b []byte) error {
b64Key := strings.Trim(string(b), "\"")
key, err := wgtypes.ParseKey(b64Key)
k.Key = key