]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdns_control make it posible to notify all zones at once
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 30 Dec 2014 11:30:11 +0000 (12:30 +0100)
committermind04 <mind04@monshouwer.org>
Tue, 6 Jan 2015 21:46:40 +0000 (22:46 +0100)
pdns/dynhandler.cc

index c0b92441d89ae2acc0e4a0d03aaf9eb469fb5900..a33008944a27961a8c15db23698f2b17e7c4dbec 100644 (file)
@@ -266,15 +266,35 @@ string DLNotifyHostHandler(const vector<string>&parts, Utility::pid_t ppid)
 string DLNotifyHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
   extern CommunicatorClass Communicator;
-  ostringstream os;
+  UeberBackend B;
   if(parts.size()!=2)
     return "syntax: notify domain";
   if(!::arg().mustDo("master"))
       return "PowerDNS not configured as master";
   L<<Logger::Warning<<"Notification request for domain '"<<parts[1]<<"' received from operator"<<endl;
-  if(!Communicator.notifyDomain(parts[1]))
-    return "Failed to add to the queue - see log";
-  return "Added to queue";
+
+  if (parts[1] == "*") {
+    vector<DomainInfo> domains;
+    B.getAllDomains(&domains);
+
+    int total = 0;
+    int notified = 0;
+    for (vector<DomainInfo>::const_iterator di=domains.begin(); di != domains.end(); di++) {
+      if (di->kind == 0) { // MASTER
+        total++;
+        if(Communicator.notifyDomain(di->zone))
+          notified++;
+      }
+    }
+
+    if (total != notified)
+      return itoa(notified)+" out of "+itoa(total)+" zones added to queue - see log";
+    return "Added "+itoa(total)+" MASTER zones to queue";
+  } else {
+    if(!Communicator.notifyDomain(parts[1]))
+      return "Failed to add to the queue - see log";
+    return "Added to queue";
+  }
 }
 
 string DLRediscoverHandler(const vector<string>&parts, Utility::pid_t ppid)