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