]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
tests: detect IPv6
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 11 Jun 2020 08:50:16 +0000 (10:50 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 3 Jul 2020 08:29:09 +0000 (10:29 +0200)
regression-tests.recursor-dnssec/recursortests.py
regression-tests.recursor-dnssec/test_ECS.py

index a9189810383750190c1e3dc6d075c129890c76a4..e321d22fd982078a04cfc7fb81b10a59e8ca6280 100644 (file)
@@ -15,6 +15,21 @@ import dns.message
 
 from eqdnsmessage import AssertEqualDNSMessageMixin
 
+
+def have_ipv6():
+    """
+    Try to make an IPv6 socket and bind it, if it fails, no ipv6...
+    """
+    try:
+        sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
+        sock.bind(('::1', 56581))
+        sock.close()
+        return True
+    except:
+        return False
+    return False
+
+
 class RecursorTest(AssertEqualDNSMessageMixin, unittest.TestCase):
     """
     Setup all recursors and auths required for the tests
@@ -499,7 +514,7 @@ distributor-threads={threads}""".format(confdir=confdir,
         authcmd = list(cls._auth_cmd)
         authcmd.append('--config-dir=%s' % confdir)
         authcmd.append('--local-address=%s' % ipaddress)
-        if (confdir[-4:] == "ROOT"):
+        if (confdir[-4:] == "ROOT") and have_ipv6():
             authcmd.append('--local-ipv6=::1')
         else:
             authcmd.append('--local-ipv6=')
index a4bdfffd20003a7c17b18e427776a02cd377a34f..d1b80505fa6f409d621ac3ef60c33fc7e1c7db51 100644 (file)
@@ -5,7 +5,8 @@ import struct
 import threading
 import time
 import clientsubnetoption
-from recursortests import RecursorTest
+import unittest
+from recursortests import RecursorTest, have_ipv6
 from twisted.internet.protocol import DatagramProtocol
 from twisted.internet import reactor
 
@@ -73,7 +74,7 @@ disable-syslog=yes
             reactor.listenUDP(port, UDPECSResponder(), interface=address)
             ecsReactorRunning = True
 
-        if not ecsReactorv6Running:
+        if not ecsReactorv6Running and have_ipv6():
             reactor.listenUDP(53000, UDPECSResponder(), interface='::1')
             ecsReactorv6Running = True
 
@@ -347,6 +348,7 @@ ecs-ipv6-cache-bits=128
         query = dns.message.make_query(nameECS, 'TXT', 'IN', use_edns=True, options=[ecso], payload=512)
         self.sendECSQuery(query, expected, ttlECS)
 
+@unittest.skipIf(not have_ipv6(), "No IPv6")
 class testIncomingECSByNameV6(ECSTest):
     _confdir = 'ECSIncomingByNameV6'