]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Remove DNSPacket from getAuth() signature 5516/head
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Thu, 13 Jul 2017 09:35:55 +0000 (11:35 +0200)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Thu, 13 Jul 2017 09:35:55 +0000 (11:35 +0200)
pdns/dnsbackend.cc
pdns/dnsbackend.hh
pdns/packethandler.cc
pdns/ueberbackend.cc
pdns/ueberbackend.hh
pdns/ws-auth.cc

index 4711bbefd3aac9a348dae699a54af7ea30aff139..5fca2b903de903a6480c3c3b47fededcdc7bbe8d 100644 (file)
@@ -33,7 +33,7 @@
 #include "dnspacket.hh"
 #include "dns.hh"
 
-bool DNSBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
+bool DNSBackend::getAuth(const DNSName &target, SOAData *sd)
 {
   return this->getSOA(target, *sd);
 }
index 86639cec1ad72f31acfea597de099ab627b8f87f..16ec7c5c4a5ab8820b1b70d5c1674cab6f442328 100644 (file)
@@ -169,7 +169,7 @@ public:
   virtual void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) { }
 
   /** Determines if we are authoritative for a zone, and at what level */
-  virtual bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
+  virtual bool getAuth(const DNSName &target, SOAData *sd);
 
   struct KeyData {
     std::string content;
index 050f2ff3f52c9fcfd5c269c580c0f7788cca783c..e4be541d29e02a92227c05066609e5d444123cd3 100644 (file)
@@ -1241,7 +1241,7 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
       return r;
     }
     
-    if(!B.getAuth(p, &sd, target)) {
+    if(!B.getAuth(target, p->qtype, &sd)) {
       DLOG(L<<Logger::Error<<"We have no authority over zone '"<<target<<"'"<<endl);
       if(!retargetcount) {
         r->setA(false); // drop AA if we never had a SOA in the first place
index 198bb9aaeb888abd729e0ff9db05d0365d88bdfd..008f2814445858372339f06ff3267026b5e59664 100644 (file)
@@ -255,7 +255,7 @@ void UeberBackend::getUpdatedMasters(vector<DomainInfo>* domains)
   }
 }
 
-bool UeberBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
+bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* sd, bool cachedOk)
 {
   bool found = false;
   int cstat;
@@ -264,7 +264,7 @@ bool UeberBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
   do {
 
     // Check cache
-    if(sd->db != (DNSBackend *)-1 && (d_cache_ttl || d_negcache_ttl)) {
+    if(cachedOk && (d_cache_ttl || d_negcache_ttl)) {
       d_question.qtype = QType::SOA;
       d_question.qname = choppedOff;
       d_question.zoneId = -1;
@@ -307,7 +307,7 @@ bool UeberBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
           break;
         } else {
           DLOG(L<<Logger::Error<<"lookup: "<<choppedOff<<endl);
-          if((*i)->getAuth(p, sd, choppedOff)) {
+          if((*i)->getAuth(choppedOff, sd)) {
             DLOG(L<<Logger::Error<<"got: "<<sd->qname<<endl);
             j->first = sd->qname.wirelength();
             j->second = *sd;
@@ -347,7 +347,7 @@ bool UeberBackend::getAuth(DNSPacket *p, SOAData *sd, const DNSName &target)
     }
 
 found:
-    if(found == (p->qtype == QType::DS)){
+    if(found == (qtype == QType::DS)){
       DLOG(L<<Logger::Error<<"found: "<<sd->qname<<endl);
       return true;
     } else {
index ece01924709517d54563d6fb7387bca3762f8fe4..63729d4a6ce2afd52ce3829856452740b45deccf 100644 (file)
@@ -98,7 +98,8 @@ public:
 
   void lookup(const QType &, const DNSName &qdomain, DNSPacket *pkt_p=0,  int zoneId=-1);
 
-  bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
+  /** Determines if we are authoritative for a zone, and at what level */
+  bool getAuth(const DNSName &target, const QType &qtype, SOAData* sd, bool cachedOk=true);
   bool getSOA(const DNSName &domain, SOAData &sd);
   bool getSOAUncached(const DNSName &domain, SOAData &sd);  // same, but ignores cache
   bool get(DNSZoneRecord &r);
index 5142fd9b043055ec4d62d5a50e0eccdb9e528031..2140e5edf546a15f6ad9e9d8c9e4b8a801424a63 100644 (file)
@@ -471,10 +471,8 @@ static void gatherRecords(const Json container, const DNSName& qname, const QTyp
       makePtr(rr, &ptr);
 
       // verify that there's a zone for the PTR
-      DNSPacket fakePacket(false);
       SOAData sd;
-      fakePacket.qtype = QType::PTR;
-      if (!B.getAuth(&fakePacket, &sd, ptr.qname))
+      if (!B.getAuth(ptr.qname, QType(QType::PTR), &sd, false))
         throw ApiException("Could not find domain for PTR '"+ptr.qname.toString()+"' requested for '"+ptr.content+"'");
 
       ptr.domain_id = sd.domain_id;
@@ -1313,12 +1311,8 @@ static void makePtr(const DNSResourceRecord& rr, DNSResourceRecord* ptr) {
 
 static void storeChangedPTRs(UeberBackend& B, vector<DNSResourceRecord>& new_ptrs) {
   for(const DNSResourceRecord& rr :  new_ptrs) {
-    DNSPacket fakePacket(false);
     SOAData sd;
-    sd.db = (DNSBackend *)-1;  // getAuth() cache bypass
-    fakePacket.qtype = QType::PTR;
-
-    if (!B.getAuth(&fakePacket, &sd, rr.qname))
+    if (!B.getAuth(rr.qname, QType(QType::PTR), &sd, false))
       throw ApiException("Could not find domain for PTR '"+rr.qname.toString()+"' requested for '"+rr.content+"' (while saving)");
 
     string soa_edit_api_kind;