Closed zvyn closed 10 years ago
This is just a quirk of the string representation for an IpRange. All addresses in the IPv4 range are also valid IPv6 addresses. Internally IpRange treats all addresses as long integers. In repr and str the class chooses the to use either the IPv4 or IPv6 string representation for addresses based on the magnitude of the largest address in the range. If the largest address is greater than 255.255.255.255 (4294967295) the IPv6 representation is used, otherwise the IPv4 representation is chosen.
I understand that this is not trivial to fix, but I needed to find out if two IP-addresses are equal (I use the repr-function for that). Some distinction between IPv4 and IPv6 would have been useful.
>>> iptools.IpRange('::1', '::2') == iptools.IpRange('0.0.0.1', '0.0.0.2')
True
A possible solution would be to store IP-adresses as touples (bool: is_ip4, long: ip). Or as a hack: just add 2^128 to any IPv6-address. I fully understand if you do not want to implement this and I have another way to work around that issue in my project, so just wanted to tell you that for me it's still a bug and [won't fix] might be the right tag :)
Nevertheless, thanks for you great work!
An address in the form '::N' (with N being a Hexadecimal digit) is interpreted as IPv4-address.
Example: