mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
bpo-35545: Fix asyncio discarding IPv6 scopes (GH-11271)
This PR proposes a solution to [bpo-35545](https://bugs.python.org/issue35545) by adding an optional `flowinfo` and `scopeid` to `asyncio.base_events._ipaddr_info` to carry the full address information into `_ipaddr_info` and avoid discarding IPv6 specific information. Changelog entry & regression tests to come. https://bugs.python.org/issue35545
This commit is contained in:
parent
14514d9084
commit
ac8eb8f36b
3 changed files with 27 additions and 3 deletions
|
@ -102,7 +102,7 @@ def _set_reuseport(sock):
|
|||
'SO_REUSEPORT defined but not implemented.')
|
||||
|
||||
|
||||
def _ipaddr_info(host, port, family, type, proto):
|
||||
def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0):
|
||||
# Try to skip getaddrinfo if "host" is already an IP. Users might have
|
||||
# handled name resolution in their own code and pass in resolved IPs.
|
||||
if not hasattr(socket, 'inet_pton'):
|
||||
|
@ -151,7 +151,7 @@ def _ipaddr_info(host, port, family, type, proto):
|
|||
socket.inet_pton(af, host)
|
||||
# The host has already been resolved.
|
||||
if _HAS_IPv6 and af == socket.AF_INET6:
|
||||
return af, type, proto, '', (host, port, 0, 0)
|
||||
return af, type, proto, '', (host, port, flowinfo, scopeid)
|
||||
else:
|
||||
return af, type, proto, '', (host, port)
|
||||
except OSError:
|
||||
|
@ -1348,7 +1348,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
family=0, type=socket.SOCK_STREAM,
|
||||
proto=0, flags=0, loop):
|
||||
host, port = address[:2]
|
||||
info = _ipaddr_info(host, port, family, type, proto)
|
||||
info = _ipaddr_info(host, port, family, type, proto, *address[2:])
|
||||
if info is not None:
|
||||
# "host" is already a resolved IP.
|
||||
return [info]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue