]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Formatting
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 22 Sep 2022 15:16:12 +0000 (17:16 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 26 Sep 2022 08:43:04 +0000 (10:43 +0200)
pdns/communicator.hh
pdns/mastercommunicator.cc

index 78746ffe00e05b7f110efd5e5ed756ae2996336e..c96795ee5afc4411c3f2a60f23f4d15abd0f687a 100644 (file)
@@ -82,14 +82,14 @@ public:
     d_nqueue.push_back(nr);
   }
 
-  bool removeIf(const string &remote, uint16_t id, const DNSName &domain)
+  bool removeIf(const string& remote, uint16_t id, const DNSName& domain)
   {
     ServiceTuple stRemote, stQueued;
     parseService(remote, stRemote);
 
-    for(d_nqueue_t::iterator i=d_nqueue.begin(); i!=d_nqueue.end(); ++i) {
+    for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i) {
       parseService(i->ip, stQueued);
-      if(i->id==id && stQueued.host == stRemote.host && i->domain==domain) {
+      if (i->id == id && stQueued.host == stRemote.host && i->domain == domain) {
         d_nqueue.erase(i);
         return true;
       }
@@ -99,7 +99,7 @@ public:
 
   bool getOne(DNSName &domain, string &ip, uint16_t *id, bool &purged)
   {
-    for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i) 
+    for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
       if(i->next <= time(0)) {
         i->attempts++;
         purged=false;
@@ -119,8 +119,8 @@ public:
 
   time_t earliest()
   {
-    time_t early=std::numeric_limits<time_t>::max() - 1; 
-    for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i) 
+    time_t early=std::numeric_limits<time_t>::max() - 1;
+    for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
       early=min(early,i->next);
     return early-time(0);
   }
@@ -150,7 +150,7 @@ struct ZoneStatus;
 class CommunicatorClass
 {
 public:
-  CommunicatorClass() 
+  CommunicatorClass()
   {
     d_tickinterval=60;
     d_slaveschanged = true;
@@ -160,8 +160,8 @@ public:
   }
   time_t doNotifications(PacketHandler *P);
   void go();
-  
-  
+
+
   void drillHole(const DNSName &domain, const string &ip);
   bool justNotified(const DNSName &domain, const string &ip);
   void addSuckRequest(const DNSName &domain, const ComboAddress& master, SuckRequest::RequestPriority, bool force=false);
@@ -227,7 +227,7 @@ private:
   {
     explicit RemoveSentinel(const DNSName& dn, CommunicatorClass* cc) : d_dn(dn), d_cc(cc)
     {}
-    
+
     ~RemoveSentinel()
     {
       try {
@@ -251,7 +251,7 @@ public:
     vector<string> addresses;
 
     this->resolve_name(&addresses, name);
-    
+
     if(b) {
         b->lookup(QType(QType::ANY),name,-1);
         DNSZoneRecord rr;
index 102a48475799741cc52f0c9c98d39fe96b846284..ac7dfd8c39697dc0d12cf6f4155f8b1e22964c9a 100644 (file)
@@ -126,7 +126,7 @@ bool CommunicatorClass::notifyDomain(const DNSName &domain, UeberBackend* B)
   if (di.serial != di.notified_serial)
     di.backend->setNotified(di.id, di.serial);
 
-  return true; 
+  return true;
 }
 
 void NotificationQueue::dump()
@@ -212,9 +212,9 @@ void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
   }
 }
 
-time_t CommunicatorClass::doNotifications(PacketHandler *P)
+time_t CommunicatorClass::doNotifications(PacketHandlerP)
 {
-  UeberBackend *B=P->getBackend();
+  UeberBackend* B = P->getBackend();
   ComboAddress from;
   Utility::socklen_t fromlen;
   char buffer[1500];
@@ -223,59 +223,58 @@ time_t CommunicatorClass::doNotifications(PacketHandler *P)
   set<int> fds = {d_nsock4, d_nsock6};
 
   // receive incoming notifications on the nonblocking socket and take them off the list
-  while(waitForMultiData(fds, 0, 0, &sock) > 0) {
-    fromlen=sizeof(from);
-    size=recvfrom(sock,buffer,sizeof(buffer),0,(struct sockaddr *)&from,&fromlen);
-    if(size < 0)
+  while (waitForMultiData(fds, 0, 0, &sock) > 0) {
+    fromlen = sizeof(from);
+    size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen);
+    if (size < 0)
       break;
     DNSPacket p(true);
 
     p.setRemote(&from);
 
-    if(p.parse(buffer,(size_t)size)<0) {
-      g_log<<Logger::Warning<<"Unable to parse SOA notification answer from "<<p.getRemote()<<endl;
+    if (p.parse(buffer, (size_t)size) < 0) {
+      g_log << Logger::Warning << "Unable to parse SOA notification answer from " << p.getRemote() << endl;
       continue;
     }
 
-    if(p.d.rcode)
-      g_log<<Logger::Warning<<"Received unsuccessful notification report for '"<<p.qdomain<<"' from "<<from.toStringWithPort()<<", error: "<<RCode::to_s(p.d.rcode)<<endl;      
+    if (p.d.rcode)
+      g_log << Logger::Warning << "Received unsuccessful notification report for '" << p.qdomain << "' from " << from.toStringWithPort() << ", error: " << RCode::to_s(p.d.rcode) << endl;
 
-    if(d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
-      g_log<<Logger::Notice<<"Removed from notification list: '"<<p.qdomain<<"' to "<<from.toStringWithPort()<<" "<< (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)")<<endl;
+    if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
+      g_log << Logger::Notice << "Removed from notification list: '" << p.qdomain << "' to " << from.toStringWithPort() << " " << (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)") << endl;
     else {
-      g_log<<Logger::Warning<<"Received spurious notify answer for '"<<p.qdomain<<"' from "<< from.toStringWithPort()<<endl;
-      //d_nq.dump();
+      g_log << Logger::Warning << "Received spurious notify answer for '" << p.qdomain << "' from " << from.toStringWithPort() << endl;
+      // d_nq.dump();
     }
   }
 
   // send out possible new notifications
   DNSName domain;
   string ip;
-  uint16_t id=0;
+  uint16_t id = 0;
 
   bool purged;
-  while(d_nq.getOne(domain, ip, &id, purged)) {
-    if(!purged) {
+  while (d_nq.getOne(domain, ip, &id, purged)) {
+    if (!purged) {
       try {
         ComboAddress remote(ip, 53); // default to 53
-        if((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) ||
-           (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) {
-             g_log<<Logger::Warning<<"Unable to notify "<<remote.toStringWithPort()<<" for domain '"<<domain<<"', address family is disabled. Is an IPv"<<(remote.sin4.sin_family == AF_INET ? "4" : "6")<<" address set in query-local-address?"<<endl;
-             d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify
-             continue; // don't try to notify what we can't!
+        if ((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) || (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) {
+          g_log << Logger::Warning << "Unable to notify " << remote.toStringWithPort() << " for domain '" << domain << "', address family is disabled. Is an IPv" << (remote.sin4.sin_family == AF_INET ? "4" : "6") << " address set in query-local-address?" << endl;
+          d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify
+          continue; // don't try to notify what we can't!
         }
-        if(d_preventSelfNotification && AddressIsUs(remote))
+        if (d_preventSelfNotification && AddressIsUs(remote))
           continue;
 
         sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B);
         drillHole(domain, ip);
       }
-      catch(ResolverException &re) {
-        g_log<<Logger::Warning<<"Error trying to resolve '"<<ip<<"' for notifying '"<<domain<<"' to server: "<<re.reason<<endl;
+      catch (ResolverException& re) {
+        g_log << Logger::Warning << "Error trying to resolve '" << ip << "' for notifying '" << domain << "' to server: " << re.reason << endl;
       }
     }
     else
-      g_log<<Logger::Warning<<"Notification for "<<domain<<" to "<<ip<<" failed after retries"<<endl;
+      g_log << Logger::Warning << "Notification for " << domain << " to " << ip << " failed after retries" << endl;
   }
 
   return d_nq.earliest();
@@ -296,7 +295,7 @@ void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const
   vector<uint8_t> packet;
   DNSPacketWriter pw(packet, domain, QType::SOA, 1, Opcode::Notify);
   pw.getHeader()->id = id;
-  pw.getHeader()->aa = true; 
+  pw.getHeader()->aa = true;
 
   if (tsigkeyname.empty() == false) {
     if (!B->getTSIGKey(tsigkeyname, tsigalgorithm, tsigsecret64)) {
@@ -343,7 +342,7 @@ bool CommunicatorClass::justNotified(const DNSName &domain, const string &ip)
     return true;
   }
 
-  // do we want to purge this? XXX FIXME 
+  // do we want to purge this? XXX FIXME
   return false;
 }