2
0

Encode from net.IP to inet and cidr

This commit is contained in:
Jack Christensen
2015-09-09 18:49:20 -05:00
parent ee7d621528
commit 8b296b9d58
4 changed files with 53 additions and 0 deletions
+4
View File
@@ -1196,6 +1196,10 @@ func encodeInet(w *WriteBuf, value interface{}) error {
switch value := value.(type) {
case net.IPNet:
ipnet = value
case net.IP:
ipnet.IP = value
bitCount := len(value) * 8
ipnet.Mask = net.CIDRMask(bitCount, bitCount)
default:
return fmt.Errorf("Expected net.IPNet, received %T %v", value, value)
}