IPV4LENGTH = 32
IPV6LENGTH = 128
+
class AddressValueError(ValueError):
"""A Value Error related to the address."""
Returns:
A boolean, True if the address is reserved per
- iana-ipv6-special-registry.
+ iana-ipv6-special-registry, or is ipv4_mapped and is
+ reserved in the iana-ipv4-special-registry.
"""
+ ipv4_mapped = self.ipv4_mapped
+ if ipv4_mapped is not None:
+ return ipv4_mapped.is_private
return any(self in net for net in self._constants._private_networks)
@property
self.assertEqual(ipaddress.ip_address('::ffff:c0a8:101').ipv4_mapped,
ipaddress.ip_address('192.168.1.1'))
+ def testIpv4MappedPrivateCheck(self):
+ self.assertEqual(
+ True, ipaddress.ip_address('::ffff:192.168.1.1').is_private)
+ self.assertEqual(
+ False, ipaddress.ip_address('::ffff:172.32.0.0').is_private)
+
def testAddrExclude(self):
addr1 = ipaddress.ip_network('10.1.1.0/24')
addr2 = ipaddress.ip_network('10.1.1.0/26')