-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Improve the textual representation of IPv4-mapped IPv6 addresses #87799
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
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 <andrew.svetlov@gmail.com>
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 <10796600+picnixz@users.noreply.github.com>
…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 <10796600+picnixz@users.noreply.github.com>
…6 addresses (pythonGH-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). --------- (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…6 addresses (pythonGH-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). --------- (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…6 addresses (pythonGH-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). --------- (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…6 addresses (pythonGH-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). --------- (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…v6 addresses (GH-29345) (GH-135080) 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). (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…v6 addresses (GH-29345) (GH-135081) 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). (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…6 addresses (GH-29345) (GH-135078) 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). (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…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 <10796600+picnixz@users.noreply.github.com>
…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 <10796600+picnixz@users.noreply.github.com>
…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 <10796600+picnixz@users.noreply.github.com>
…v6 addresses (GH-29345) (GH-135079) 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). (cherry picked from commit f22bf8e) Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…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 <10796600+picnixz@users.noreply.github.com>
I'd like to express my concern that this change got backported to all these patch releases of Python. Surely the feature is not so important that everyone needs to get it immediately? Compared to the tradeoff that this is supposed to be bugfixes-only? As I'm rushing to apply the latest security release, I see that the patch release also changed our code that produces IPv6 addresses to now produce |
Uh oh!
There was an error while loading. Please reload this page.
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:
Linked PRs
The text was updated successfully, but these errors were encountered: