]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Drop UeberBackend::get(DNSResourceRecord&)
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Fri, 7 Oct 2016 11:38:15 +0000 (13:38 +0200)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Thu, 8 Dec 2016 16:53:44 +0000 (17:53 +0100)
pdns/backends/gsql/gsqlbackend.cc
pdns/communicator.hh
pdns/mastercommunicator.cc
pdns/slavecommunicator.cc
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index da28653d0620ab10cfbca6dd39f20c48dcfd839a..996cf5c019db3e3efa48f08a5430d636f2fa9d4f 100644 (file)
@@ -399,8 +399,8 @@ void GSQLBackend::getUpdatedMasters(vector<DomainInfo> *updatedDomains)
   }
 
   vector<DomainInfo> allMasters;
-  int numanswers=d_result.size();
-  for(int n=0;n<numanswers;++n) { // id,name,master,last_check,notified_serial
+  size_t numanswers=d_result.size();
+  for(size_t n=0;n<numanswers;++n) { // id,name,master,last_check,notified_serial
     DomainInfo sd;
     ASSERT_ROW_COLUMNS("info-all-master-query", d_result[n], 6);
     sd.id=pdns_stou(d_result[n][0]);
index 065dae952ce62b838be504a9e6e80fe1c8355567..9c2e217572bd71b365cb8943a6b7dae34b96fcfe 100644 (file)
@@ -159,7 +159,6 @@ public:
     d_masterschanged=d_slaveschanged=true;
     d_nsock4 = -1;
     d_nsock6 = -1;
-    d_havepriosuckrequest = false;
     d_preventSelfNotification = false;
   }
   time_t doNotifications();    
@@ -189,11 +188,10 @@ public:
   bool notifyDomain(const DNSName &domain);
 private:
   void makeNotifySockets();
-  void queueNotifyDomain(const DNSName &domain, UeberBackend *B);
+  void queueNotifyDomain(const DomainInfo& di, UeberBackend* B);
   int d_nsock4, d_nsock6;
   map<pair<DNSName,string>,time_t>d_holes;
   pthread_mutex_t d_holelock;
-  void launchRetrievalThreads();
   void suck(const DNSName &domain, const string &remote);
   void ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, boost::scoped_ptr<AuthLua>& pdl,
                 ZoneStatus& zs, vector<DNSRecord>* axfr);
@@ -213,7 +211,6 @@ private:
   set<string> d_alsoNotify;
   NotificationQueue d_nq;
   NetmaskGroup d_onlyNotify;
-  bool d_havepriosuckrequest;
   bool d_masterschanged, d_slaveschanged;
   bool d_preventSelfNotification;
 
@@ -253,22 +250,6 @@ public:
     return addresses;
   }
 
-  vector<string> lookup(const DNSName &name, UeberBackend *b)
-  {
-    vector<string> addresses;
-
-    this->resolve_name(&addresses, name);
-
-    if(b) {
-        b->lookup(QType(QType::ANY),name);
-        DNSResourceRecord rr;
-        while(b->get(rr))
-          if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA)
-             addresses.push_back(rr.content);   // SOL if you have a CNAME for an NS
-    }
-    return addresses;
-  }
-
 private:
   void resolve_name(vector<string>* addresses, const DNSName& name)
   {
index 76a2bb102628d5468763081cbe55e312625b8477..930304149d9f324dcf4f31f36a9a061b7abeae3d 100644 (file)
 #include "namespaces.hh"
 
 
-void CommunicatorClass::queueNotifyDomain(const DNSName &domain, UeberBackend *B)
+void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B)
 {
   bool hasQueuedItem=false;
   set<string> nsset, ips;
   DNSResourceRecord rr;
   FindNS fns;
 
-  B->lookup(QType(QType::NS),domain);
-  while(B->get(rr))
+  di.backend->lookup(QType(QType::NS), di.zone);
+  while(di.backend->get(rr))
     nsset.insert(rr.content);
 
   for(set<string>::const_iterator j=nsset.begin();j!=nsset.end();++j) {
-    vector<string> nsips=fns.lookup(DNSName(*j), B);
+    vector<string> nsips=fns.lookup(DNSName(*j), di.backend);
     if(nsips.empty())
-      L<<Logger::Warning<<"Unable to queue notification of domain '"<<domain<<"': nameservers do not resolve!"<<endl;
+      L<<Logger::Warning<<"Unable to queue notification of domain '"<<di.zone<<"': nameservers do not resolve!"<<endl;
     else
       for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) {
         const ComboAddress caIp(*k, 53);
         if(!d_preventSelfNotification || !AddressIsUs(caIp)) {
           if(!d_onlyNotify.match(&caIp))
-            L<<Logger::Info<<"Skipped notification of domain '"<<domain<<"' to "<<*j<<" because it does not match only-notify."<<endl;
+            L<<Logger::Info<<"Skipped notification of domain '"<<di.zone<<"' to "<<*j<<" because it does not match only-notify."<<endl;
           else
             ips.insert(caIp.toStringWithPort());
         }
@@ -70,31 +70,31 @@ void CommunicatorClass::queueNotifyDomain(const DNSName &domain, UeberBackend *B
   }
 
   for(set<string>::const_iterator j=ips.begin();j!=ips.end();++j) {
-    L<<Logger::Warning<<"Queued notification of domain '"<<domain<<"' to "<<*j<<endl;
-    d_nq.add(domain,*j);
+    L<<Logger::Warning<<"Queued notification of domain '"<<di.zone<<"' to "<<*j<<endl;
+    d_nq.add(di.zone,*j);
     hasQueuedItem=true;
   }
 
   set<string> alsoNotify(d_alsoNotify);
-  B->alsoNotifies(domain, &alsoNotify);
+  B->alsoNotifies(di.zone, &alsoNotify);
 
   for(set<string>::const_iterator j=alsoNotify.begin();j!=alsoNotify.end();++j) {
     try {
       const ComboAddress caIp(*j, 53);
-      L<<Logger::Warning<<"Queued also-notification of domain '"<<domain<<"' to "<<caIp.toStringWithPort()<<endl;
+      L<<Logger::Warning<<"Queued also-notification of domain '"<<di.zone<<"' to "<<caIp.toStringWithPort()<<endl;
       if (!ips.count(caIp.toStringWithPort())) {
         ips.insert(caIp.toStringWithPort());
-        d_nq.add(domain, caIp.toStringWithPort());
+        d_nq.add(di.zone, caIp.toStringWithPort());
       }
       hasQueuedItem=true;
     }
     catch(PDNSException &e) {
-      L<<Logger::Warning<<"Unparseable IP in ALSO-NOTIFY metadata of domain '"<<domain<<"'. Warning: "<<e.reason<<endl;
+      L<<Logger::Warning<<"Unparseable IP in ALSO-NOTIFY metadata of domain '"<<di.zone<<"'. Warning: "<<e.reason<<endl;
     }
   }
 
   if (!hasQueuedItem)
-    L<<Logger::Warning<<"Request to queue notification for domain '"<<domain<<"' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
+    L<<Logger::Warning<<"Request to queue notification for domain '"<<di.zone<<"' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
 }
 
 
@@ -106,7 +106,7 @@ bool CommunicatorClass::notifyDomain(const DNSName &domain)
     L<<Logger::Error<<"No such domain '"<<domain<<"' in our database"<<endl;
     return false;
   }
-  queueNotifyDomain(domain, &B);
+  queueNotifyDomain(di, &B);
   // call backend and tell them we sent out the notification - even though that is premature    
   di.backend->setNotified(di.id, di.serial);
 
@@ -145,11 +145,11 @@ void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
   // figure out A records of everybody needing notification
   // do this via the FindNS class, d_fns
   
-  for(vector<DomainInfo>::const_iterator i=cmdomains.begin();i!=cmdomains.end();++i) {
+  for(auto& di : cmdomains) {
     extern PacketCache PC;
-    PC.purgeExact(i->zone);
-    queueNotifyDomain(i->zone,P->getBackend());
-    i->backend->setNotified(i->id,i->serial); 
+    PC.purgeExact(di.zone);
+    queueNotifyDomain(di, B);
+    di.backend->setNotified(di.id, di.serial);
   }
 }
 
index 56724320b812eb565db006e215fee011ca980027..9e481abb35163df11abb5be2fb735afca50f3815 100644 (file)
@@ -134,11 +134,13 @@ void CommunicatorClass::ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, c
 
       di.backend->startTransaction(domain, -1);
       for(const auto g : grouped) {
-        DNSResourceRecord rr;
         vector<DNSRecord> rrset;
-        B.lookup(QType(g.first.second), g.first.first, 0, di.id);
-        while(B.get(rr)) {
-          rrset.push_back(DNSRecord{rr});
+        {
+          DNSZoneRecord zrr;
+          B.lookup(QType(g.first.second), g.first.first, 0, di.id);
+          while(B.get(zrr)) {
+            rrset.push_back(zrr.dr);
+          }
         }
         // O(N^2)!
         rrset.erase(remove_if(rrset.begin(), rrset.end(), 
@@ -851,13 +853,13 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P)
       }
       else {
         B->lookup(QType(QType::RRSIG), di.zone); // can't use DK before we are done with this lookup!
-        DNSResourceRecord rr;
+        DNSZoneRecord zr;
         uint32_t maxExpire=0, maxInception=0;
-        while(B->get(rr)) {
-          RRSIGRecordContent rrc(rr.content);
-          if(rrc.d_type == QType::SOA) {
-            maxInception = std::max(maxInception, rrc.d_siginception);
-            maxExpire = std::max(maxExpire, rrc.d_sigexpire);
+        while(B->get(zr)) {
+          auto rrsig = getRR<RRSIGRecordContent>(zr.dr);
+          if(rrsig->d_type == QType::SOA) {
+            maxInception = std::max(maxInception, rrsig->d_siginception);
+            maxExpire = std::max(maxExpire, rrsig->d_sigexpire);
           }
         }
         if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) {
index edb1e42ea1c829033571d820253d21ce7dce07b7..40c5c064414f221daa3900710b1e99eeca8ece1b 100644 (file)
@@ -579,19 +579,6 @@ void UeberBackend::getAllDomains(vector<DomainInfo> *domains, bool include_disab
   }
 }
 
-bool UeberBackend::get(DNSResourceRecord &rr)
-{
-  // cout<<"UeberBackend::get(DNSResourceRecord&) called, translating to a DNSZoneRecord query"<<endl;
-  DNSZoneRecord dzr;
-  if(!this->get(dzr))
-    return false;
-
-  rr=DNSResourceRecord(dzr.dr);
-  rr.auth = dzr.auth;
-  rr.domain_id = dzr.domain_id;
-  return true;
-}
-
 bool UeberBackend::get(DNSZoneRecord &rr)
 {
   // cout<<"UeberBackend::get(DNSZoneRecord) called"<<endl;
index acecf9c8d6b04a161e156ca32e3df9565e5b5f90..af913334fbe13cfc3809e6d3d8d4d2e0015a58b3 100644 (file)
@@ -105,7 +105,6 @@ public:
   bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
   bool getSOA(const DNSName &domain, SOAData &sd, DNSPacket *p=0);
   bool getSOAUncached(const DNSName &domain, SOAData &sd, DNSPacket *p=0);  // same, but ignores cache
-  bool get(DNSResourceRecord &r);
   bool get(DNSZoneRecord &r);
   void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);