When I use
|
func NextIP(ip net.IP) net.IP { |
|
i := ipToInt(ip) |
|
return intToIP(i.Add(i, big.NewInt(1))) |
|
} |
to get next IP of address "0.0.0.1", I got an illegal result
[2] but not an expected one
[0,0,0,2].
This is because intToIP does not obey the byte length of IPv4(4)/IPv6(16) when first byte is 0.
|
func intToIP(i *big.Int) net.IP { |
|
return net.IP(i.Bytes()) |
|
} |
This bug will happen when first byte is 0 no matter family is IPv4 or IPv6.
When I use
plugins/pkg/ip/cidr.go
Lines 23 to 26 in 7e9ada5
[2]but not an expected one[0,0,0,2].This is because
intToIPdoes not obey the byte length of IPv4(4)/IPv6(16) when first byte is 0.plugins/pkg/ip/cidr.go
Lines 51 to 53 in 7e9ada5
This bug will happen when first byte is 0 no matter family is IPv4 or IPv6.