mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-33433 Fix private address checking for IPv4 mapped IPv6. (GH-26172)
For IPv4 mapped IPv6 addresses, defer privacy check to the mapped IPv4 address. Solves bug where public mapped IPv4 addresses are considered private by the IPv6 check. Automerge-Triggered-By: GH:gpshead
This commit is contained in:
parent
c10392e7dd
commit
83f0f8d62f
3 changed files with 13 additions and 1 deletions
|
@ -16,6 +16,7 @@ import functools
|
|||
IPV4LENGTH = 32
|
||||
IPV6LENGTH = 128
|
||||
|
||||
|
||||
class AddressValueError(ValueError):
|
||||
"""A Value Error related to the address."""
|
||||
|
||||
|
@ -2002,9 +2003,13 @@ class IPv6Address(_BaseV6, _BaseAddress):
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue