ipv6: getaddrinfo would fail with scope index

Discard any '%' delimited suffix.

https://github.com/eventlet/eventlet/pull/322
This commit is contained in:
Jarrod Johnson
2016-06-02 14:37:50 -04:00
committed by Sergey Shepelev
parent 23ea43a65f
commit ac4e28fd1a
2 changed files with 8 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ def is_ipv6_addr(host):
"""Return True if host is a valid IPv6 address"""
if not isinstance(host, six.string_types):
return False
host = host.split('%', 1)[0]
try:
dns.ipv6.inet_aton(host)
except dns.exception.SyntaxError:

View File

@@ -62,3 +62,10 @@ def test_socket_api_family():
# It was named family_or_realsock
# https://github.com/eventlet/eventlet/issues/319
socket.socket(family=socket.AF_INET)
def test_getaddrinfo_ipv6_scope():
greendns.is_ipv6_addr('::1%2')
if not socket.has_ipv6:
return
socket.getaddrinfo('::1%2', 80, socket.AF_INET6)