def dnsapi_getdomainmetadata(self, qname, qkind):
     """pdns getDomainMetadata api"""
     self.QueryCounter.labels('getDomainMetadata').inc()
     log.debug('QUERY: %s %s', qname, qkind)
     if qkind == 'SOA-EDIT':
         # http://jpmens.net/2013/01/18/understanding-powerdns-soa-edit/
         return dnsresponse(['EPOCH'])
     else:
         return dnsresponse(False)
def dnsresponse(data):
    """Construct a response for the PowerDNS remote backend.

    Remote api docs:
        https://doc.powerdns.com/md/authoritative/backend-remote/
    """
    resp = {'result': list(data or [])}
    log.debug('DNS response: %s', resp)
    return resp
 def dnsapi_lookup(self, qname, qtype):
     """pdns lookup api"""
     log.debug('QUERY: %s %s', qname, qtype)
     self.QueryCounter.labels('lookup').inc()
     self.LookupCounter.labels('qtype').inc()
     # TODO: better ANY handling (what's even correct here?)
     with self.LookupTimer.labels(qtype).time():
         if qtype == 'ANY':
             return dnsresponse(itertools.chain(
                 self.a_lookup(qname),
                 self.ns_lookup(qname),
                 self.soa_lookup(qname),
                 self.srv_lookup(qname)))
         elif qtype == 'A':
             return dnsresponse(self.a_lookup(qname))
         elif qtype == 'NS':
             return dnsresponse(self.ns_lookup(qname))
         elif qtype == 'SOA':
             return dnsresponse(self.soa_lookup(qname))
         elif qtype == 'SRV':
             return dnsresponse(self.srv_lookup(qname))
         else:
             return dnsresponse(False)