def postOptions(self): if self["resolv-conf"]: self["recursive"] = True self.svcs = [] self.zones = [] for f in self.zonefiles: try: self.zones.append(authority.PySourceAuthority(f)) except Exception: traceback.print_exc() raise usage.UsageError("Invalid syntax in " + f) for f in self.bindfiles: try: self.zones.append(authority.BindAuthority(f)) except Exception: traceback.print_exc() raise usage.UsageError("Invalid syntax in " + f) for f in self.secondaries: svc = secondary.SecondaryAuthorityService.fromServerAddressAndDomains(*f) self.svcs.append(svc) self.zones.append(self.svcs[-1].getAuthority()) try: self["port"] = int(self["port"]) except ValueError: raise usage.UsageError("Invalid port: %r" % (self["port"],))
def __init__(self, config, test_obj): """Initialize and configure the DNS object.""" zones = [] port = config.get('port', 10053) pyzones = config.get('python-zones', []) bindzones = config.get('bind-zones', []) for pyzone in pyzones: zones.append(authority.PySourceAuthority( '%s/dns_zones/%s' % (test_obj.test_name, pyzone))) LOGGER.info("Added Python zone file %s" % (pyzone)) for bindzone in bindzones: zones.append(authority.BindAuthority( '%s/dns_zones/%s' % (test_obj.test_name, bindzone))) LOGGER.info("Added BIND zone file %s" % (bindzone)) factory = server.DNSServerFactory(authorities=zones) protocol = dns.DNSDatagramProtocol(controller=factory) reactor.listenUDP(port, protocol) reactor.listenTCP(port, factory) LOGGER.info("Started DNS server (UDP and TCP) on port %d" % (port))
def postOptions(self): if self['resolv-conf']: self['recursive'] = True self.svcs = [] self.zones = [] for f in self.zonefiles: try: self.zones.append(authority.PySourceAuthority(f)) except Exception, e: traceback.print_exc() raise usage.UsageError("Invalid syntax in " + f)
def loadPySourceString(self, s): """ Create a new L{twisted.names.authority.PySourceAuthority} from C{s}. @param s: A string with BIND zone data in a Python source file. @type s: L{str} @return: a new bind authority @rtype: L{twisted.names.authority.PySourceAuthority} """ fp = FilePath(self.mktemp()) with open(fp.path, "w") as f: f.write(s) return authority.PySourceAuthority(fp.path)