Skip to content

Update Python tracking to support scoped IPv6 addresses #54

Description

@jamver

Please update the package to include the recently added support for IPv6 Scoped Literal Addresses added to Python3.9a5 python/cpython@21da76d.

The IPv6 address Wikipedia article has a good description of scoped literal IPv6 addresses — Scoped literal addresses are IPv6 address appended by '%' and a scope or zone id value — typically an interface numeric identifier on Windows and an interface name on Unix-based systems.

Testing using phihag/ipaddress@ d8aef06 version 1.0.23 (latest):

Python 2.7.9 (default, Sep 14 2019, 20:00:08)
[GCC 4.9.2] on linux2

>>> import ipaddress

>>> ipaddress.ip_address(u'::1')
IPv6Address(u'::1')

>>> ipaddress.ip_address(u'::1%1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ipaddress.py", line 168, in ip_address address)
ValueError: u'::1%1' does not appear to be an IPv4 or IPv6 address

Testing using python/cpython@dcd4c4f version 3.9.0a5:

Python 3.9.0a5 (v3.9.0a5:dcd4c4f9c9, Mar 23 2020, 14:59:02)
[Clang 6.0 (clang-600.0.57)] on darwin

>>> import ipaddress

>>> ipaddress.ip_address(u'::1')
IPv6Address('::1')

>>> ipaddress.ip_address(u'::1%1')
IPv6Address('::1%1')

(For background, this is normal behaviour for Python's socket.socket.accept(), which is a transliteration of the underlying system call. On Unix-based systems (such as Linux), sockaddr_storage (sockaddr_in6 from ip6(7)) includes sin6_scope_id (ifr_ifindex from netdevice(7)), and is returned as the interface name (represented as %ifr_ifname) when being returned as a string by the Python2.7 sockets library (python/cpython@7a41638 2.7.18rc1/Modules/socketmodule.c#L1366).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions