From ac4e28fd1a52dc6488ed5d80e37db19a2ed997dd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 2 Jun 2016 14:37:50 -0400 Subject: [PATCH] ipv6: getaddrinfo would fail with scope index Discard any '%' delimited suffix. https://github.com/eventlet/eventlet/pull/322 --- eventlet/support/greendns.py | 1 + tests/socket_test.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py index e796b64..cf11591 100644 --- a/eventlet/support/greendns.py +++ b/eventlet/support/greendns.py @@ -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: diff --git a/tests/socket_test.py b/tests/socket_test.py index 8fcaaa3..09afc5d 100644 --- a/tests/socket_test.py +++ b/tests/socket_test.py @@ -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)