mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-109466: Add ipv6_mapped property to IPv4Address (#109467)
Adds the `IPv4Address.ipv6_mapped` property. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
24b5cbd3dc
commit
ba8aa1fd37
5 changed files with 32 additions and 0 deletions
|
@ -1389,6 +1389,16 @@ class IPv4Address(_BaseV4, _BaseAddress):
|
|||
"""
|
||||
return self in self._constants._linklocal_network
|
||||
|
||||
@property
|
||||
def ipv6_mapped(self):
|
||||
"""Return the IPv4-mapped IPv6 address.
|
||||
|
||||
Returns:
|
||||
The IPv4-mapped IPv6 address per RFC 4291.
|
||||
|
||||
"""
|
||||
return IPv6Address(f'::ffff:{self}')
|
||||
|
||||
|
||||
class IPv4Interface(IPv4Address):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue