From: Pieter Lexis Date: Thu, 11 Jun 2020 08:50:16 +0000 (+0200) Subject: tests: detect IPv6 X-Git-Tag: rec-4.4.0-beta1~56^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb027663d9d19ad70149714fb002ea37c5a13d65;p=thirdparty%2Fpdns.git tests: detect IPv6 --- diff --git a/regression-tests.recursor-dnssec/recursortests.py b/regression-tests.recursor-dnssec/recursortests.py index a918981038..e321d22fd9 100644 --- a/regression-tests.recursor-dnssec/recursortests.py +++ b/regression-tests.recursor-dnssec/recursortests.py @@ -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=') diff --git a/regression-tests.recursor-dnssec/test_ECS.py b/regression-tests.recursor-dnssec/test_ECS.py index a4bdfffd20..d1b80505fa 100644 --- a/regression-tests.recursor-dnssec/test_ECS.py +++ b/regression-tests.recursor-dnssec/test_ECS.py @@ -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'