summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarrod Johnson <jjohnson2@lenovo.com>2016-06-02 14:37:50 -0400
committerSergey Shepelev <temotor@gmail.com>2016-08-30 19:25:23 +0500
commitac4e28fd1a52dc6488ed5d80e37db19a2ed997dd (patch)
treed733519f49a9e5699b86179aa6470a6371943b06
parent23ea43a65f808759597317f9e6fc22909fab619a (diff)
downloadeventlet-ac4e28fd1a52dc6488ed5d80e37db19a2ed997dd.tar.gz
ipv6: getaddrinfo would fail with scope index
Discard any '%' delimited suffix. https://github.com/eventlet/eventlet/pull/322
-rw-r--r--eventlet/support/greendns.py1
-rw-r--r--tests/socket_test.py7
2 files changed, 8 insertions, 0 deletions
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)