Commit 639e23d7 authored by Arturo Filastò's avatar Arturo Filastò
Browse files

Parametrise the DNS test helper remote resolver.

parent 1dd52502
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ helpers:
        address: null
        udp_port: 57004
        tcp_port: 57005
        resolver_address: '8.8.8.8:53'

    ssl:
        address: null
+10 −1
Original line number Diff line number Diff line
@@ -3,11 +3,20 @@ from twisted.internet import reactor
from twisted.names import dns
from twisted.names import client, server

from oonib import config

class DNSTestHelper(server.DNSServerFactory):
    def __init__(self, authorities = None,
                 caches = None, clients = None,
                 verbose = 0):
        resolver = client.Resolver(servers=[('8.8.8.8', 53)])
        try:
            host, port = config.helpers.dns.split(':')
            port = int(port)
        # XXX remove this when we have configuration file versioning.
        # https://github.com/TheTorProject/ooni-probe/issues/190
        except:
            host, port = '8.8.8.8', 53
        resolver = client.Resolver(servers=[(host, port)])
        server.DNSServerFactory.__init__(self, authorities = authorities,
                                         caches = caches, clients = [resolver],
                                         verbose = verbose)