fix json marshalling of uninitialised JSONIPnet
This commit is contained in:
parent
ddb0b4c549
commit
047a0dc7be
@ -12,8 +12,12 @@ type JSONIPNet struct {
|
||||
}
|
||||
|
||||
func (n JSONIPNet) MarshalJSON() ([]byte, error) {
|
||||
if len(n.IPNet.IP) == 0 {
|
||||
return []byte("\"\""), nil
|
||||
} else {
|
||||
return []byte("\"" + n.IPNet.String() + "\""), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n *JSONIPNet) UnmarshalJSON(b []byte) error {
|
||||
cidr := strings.Trim(string(b), "\"")
|
||||
@ -36,12 +40,8 @@ func (n *JSONIPNet) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
func (n *JSONIPNet) String() string {
|
||||
if len(n.IPNet.IP) == 0 {
|
||||
return "\"\""
|
||||
} else {
|
||||
return n.IPNet.String()
|
||||
}
|
||||
}
|
||||
|
||||
type JSONKey struct {
|
||||
Key wgtypes.Key
|
||||
|
Loading…
Reference in New Issue
Block a user