-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the textual representation of IPv4-mapped IPv6 addresses #87799
Comments
Python supports IPv4-mapped IPv6 addresses as defined by RFC 4038: The current behavior is as follows: from ipaddress import ip_address
addr = ip_address('::ffff:8.8.4.4') # IPv6Address('::ffff:808:404')
addr.ipv4_mapped # IPv4Address('8.8.4.4') Note that the textual representation of the IPv6Address is *not* in IPv4-mapped format. My proposal would be to check, in __str__, if an IPv6 is an IPv4-mapped, and to return the appropriate representation : from ipaddress import ip_address
addr = ip_address('::ffff:8.8.4.4')
# Current behavior
str(addr) # '::ffff:808:404'
repr(addr) # IPv6Address('::ffff:808:404')
# Proposed behavior
str(addr) # '::ffff:8.8.4.4'
repr(addr) # IPv6Address('::ffff:8.8.4.4') A few data points:
|
@maxmouchet, thank you for creating the issue. I'll try to fix this, if you don't mind. |
…esses (#29345) Represent IPv4-mapped IPv6 address as x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of the six high-order 16-bit pieces of the address, and the 'd's are the decimal values of the four low-order 8-bit pieces of the address (standard IPv4 representation). --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <[email protected]>
Done by #29345 |
Are there any tests for the IP Address: Results in a
instead of the old:
I'm not sure which one is more valid or if a pointer record is even relevant in the context of mapped addresses. The original way seems more correct to me if nothing for the fact that there are strange extra dots in the new output. (I'll create a new issue for this since this one is closed) |
…dresses (pythonGH-123419) Fix functionality that was broken with better textual representation for IPv4-mapped addresses (pythongh-87799) (cherry picked from commit 77a2fb4) Co-authored-by: Bénédikt Tran <[email protected]>
…ddresses (GH-123419) (#123606) gh-123409: fix `IPv6Address.reverse_pointer` for IPv4-mapped addresses (GH-123419) Fix functionality that was broken with better textual representation for IPv4-mapped addresses (gh-87799) (cherry picked from commit 77a2fb4) Co-authored-by: Bénédikt Tran <[email protected]>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: