|
|
@@ -18,6 +18,7 @@ import requests
|
|
|
from docker.models.containers import Container
|
|
|
from docker.models.networks import Network
|
|
|
from packaging.version import Version
|
|
|
+from urllib3.util.connection import HAS_IPV6
|
|
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
logging.getLogger('backoff').setLevel(logging.INFO)
|
|
|
@@ -42,29 +43,6 @@ test_container = 'nginx-proxy-pytest'
|
|
|
#
|
|
|
###############################################################################
|
|
|
|
|
|
-def _has_ipv6(host: str) -> bool:
|
|
|
- """Returns True if the system can bind an IPv6 address."""
|
|
|
- sock = None
|
|
|
- has_ipv6 = False
|
|
|
-
|
|
|
- if socket.has_ipv6:
|
|
|
- # has_ipv6 returns true if cPython was compiled with IPv6 support.
|
|
|
- # It does not tell us if the system has IPv6 support enabled. To
|
|
|
- # determine that we must bind to an IPv6 address.
|
|
|
- # https://github.com/urllib3/urllib3/pull/611
|
|
|
- # https://bugs.python.org/issue658327
|
|
|
- try:
|
|
|
- sock = socket.socket(socket.AF_INET6)
|
|
|
- sock.bind((host, 0))
|
|
|
- has_ipv6 = True
|
|
|
- except Exception:
|
|
|
- pass
|
|
|
-
|
|
|
- if sock:
|
|
|
- sock.close()
|
|
|
- return has_ipv6
|
|
|
-
|
|
|
-HAS_IPV6 = _has_ipv6("::1")
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
def ipv6(force_ipv6=True):
|