Handle missing IPv6 support by the kernel
This is different from disabled IPv6. Fixes #1050
This commit is contained in:
parent
70a8d632fb
commit
6ec63ccc9b
@ -238,7 +238,9 @@ def serve(configuration, shutdown_socket):
|
||||
# Address family not available (e.g. IPv6 disabled)
|
||||
# macOS: IPv4 address for INET6 address family with
|
||||
# IPV6_V6ONLY set
|
||||
e.errno == errno.EADDRNOTAVAIL)):
|
||||
e.errno == errno.EADDRNOTAVAIL or
|
||||
# Address family not supported
|
||||
e.errno == errno.EAFNOSUPPORT)):
|
||||
continue
|
||||
raise RuntimeError("Failed to start server %r: %s" % (
|
||||
format_address(address), e)) from e
|
||||
|
@ -132,20 +132,22 @@ class TestBaseServerRequests(BaseTest):
|
||||
socket.EAI_NONAME, server.COMPAT_EAI_ADDRFAMILY,
|
||||
server.COMPAT_EAI_NODATA) or
|
||||
str(exc_info.value) == "address family mismatched" or
|
||||
exc_info.value.errno == errno.EADDRNOTAVAIL)
|
||||
exc_info.value.errno == errno.EADDRNOTAVAIL or
|
||||
exc_info.value.errno == errno.EAFNOSUPPORT)
|
||||
|
||||
def test_ipv6(self):
|
||||
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
||||
# Only allow IPv6 connections to the IPv6 socket
|
||||
sock.setsockopt(server.COMPAT_IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
|
||||
try:
|
||||
try:
|
||||
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
||||
# Only allow IPv6 connections to the IPv6 socket
|
||||
sock.setsockopt(
|
||||
server.COMPAT_IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
|
||||
# Find available port
|
||||
sock.bind(("::1", 0))
|
||||
except OSError as e:
|
||||
if e.errno == errno.EADDRNOTAVAIL:
|
||||
pytest.skip("IPv6 not supported")
|
||||
raise
|
||||
self.sockname = sock.getsockname()[:2]
|
||||
self.sockname = sock.getsockname()[:2]
|
||||
except OSError as e:
|
||||
if e.errno in (errno.EADDRNOTAVAIL, errno.EAFNOSUPPORT):
|
||||
pytest.skip("IPv6 not supported")
|
||||
raise
|
||||
self.configuration.update({
|
||||
"server": {"hosts": "[%s]:%d" % self.sockname}}, "test")
|
||||
self.thread.start()
|
||||
|
Loading…
Reference in New Issue
Block a user