]> granicus.if.org Git - pdns/commitdiff
catch ComboClass exceptions in communicator
authorKees Monshouwer <mind04@monshouwer.org>
Sat, 28 Dec 2013 20:31:45 +0000 (21:31 +0100)
committermind04 <mind04@monshouwer.org>
Sat, 28 Dec 2013 21:58:51 +0000 (22:58 +0100)
pdns/communicator.cc
pdns/mastercommunicator.cc

index 1a9ad891aeac325a31c74217b713755d51b94748..34be6a54cb3aea706fd1d202ed28dbaf41d4dfbe 100644 (file)
@@ -63,12 +63,27 @@ void CommunicatorClass::go()
     pthread_create(&tid, 0, &retrieveLaunchhelper, this); // Starts CommunicatorClass::retrievalLoopThread()
 
   d_preventSelfNotification = ::arg().mustDo("prevent-self-notification");
-  d_onlyNotify.toMasks(::arg()["only-notify"]);
+
+  try {
+    d_onlyNotify.toMasks(::arg()["only-notify"]);
+  }
+  catch(PDNSException &e) {
+    L<<Logger::Error<<"Unparseable IP in only-notify. Error: "<<e.reason<<endl;
+    exit(0);
+  }
 
   vector<string> parts;
   stringtok(parts, ::arg()["also-notify"], ", \t");
-  for (vector<string>::const_iterator iter = parts.begin(); iter != parts.end(); ++iter)
-    d_alsoNotify.insert(*iter);
+  for (vector<string>::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) {
+    try {
+      ComboAddress caIp(*iter, 53);
+      d_alsoNotify.insert(caIp.toStringWithPort());
+    }
+    catch(PDNSException &e) {
+      L<<Logger::Error<<"Unparseable IP in also-notify. Error: "<<e.reason<<endl;
+      exit(0);
+    }
+  }
 }
 
 void CommunicatorClass::mainloop(void)
index 61e79ca2fccd760e19f621e13acd97ceeceaa2e0..1d88c58f898cd4529233c7ad0c7a357f7e534894 100644 (file)
@@ -78,17 +78,22 @@ void CommunicatorClass::queueNotifyDomain(const string &domain, DNSBackend *B)
   B->alsoNotifies(domain, &alsoNotify);
 
   for(set<string>::const_iterator j=alsoNotify.begin();j!=alsoNotify.end();++j) {
-    const ComboAddress caIp(*j, 53);
-    L<<Logger::Warning<<"Queued also-notification of domain '"<<domain<<"' to "<<caIp.toStringWithPort()<<endl;
-    if (!ips.count(caIp.toStringWithPort())) {
-      ips.insert(caIp.toStringWithPort());
-      d_nq.add(domain, caIp.toStringWithPort());
+    try {
+      const ComboAddress caIp(*j, 53);
+      L<<Logger::Warning<<"Queued also-notification of domain '"<<domain<<"' to "<<caIp.toStringWithPort()<<endl;
+      if (!ips.count(caIp.toStringWithPort())) {
+        ips.insert(caIp.toStringWithPort());
+        d_nq.add(domain, caIp.toStringWithPort());
+      }
+      hasQueuedItem=true;
+    }
+    catch(PDNSException &e) {
+      L<<Logger::Warning<<"Unparseable IP in ALSO-NOTIFY metadata of domain '"<<domain<<"'. Warning: "<<e.reason<<endl;
     }
-    hasQueuedItem=true;
   }
 
   if (!hasQueuedItem)
-    L<<Logger::Warning<<"Request to queue notification for domain '"<<domain<<"' was processed, but no nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
+    L<<Logger::Warning<<"Request to queue notification for domain '"<<domain<<"' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
 }