]> granicus.if.org Git - pdns/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 16:25:05 +0000 (17:25 +0100)
docs/markdown/authoritative/internals.md
pdns/dynhandler.cc

index 2c3639e267f08ff7be3114a6923abf537d72f85f..60ef514b39ba93659ba18c10e9fc8094ec8ef85f 100644 (file)
@@ -21,7 +21,7 @@ The output has the same format as `pdns_server --config`. You'll notice that all
 Restart a PowerDNS instance. Only available when running in guardian mode.
 
 ## `notify DOMAIN`
-Adds a domain to the notification list, causing PowerDNS to send out notifications to the nameservers of a domain. Can be used if a slave missed previous notifications or is generally hard of hearing.
+Adds a domain to the notification list, causing PowerDNS to send out notifications to the nameservers of a domain. Can be used if a slave missed previous notifications or is generally hard of hearing. Use * to send notifications for all (type=MASTER) zones to all slaves.
 
 ## `notify-host DOMAIN HOST`
 Same as above but with operator specified IP address as destination, to be used if you know better than PowerDNS.
index 87522b4bd6b217171089a099d7beec586ca01827..79c5f42895b18d301a8b4b5bed8b5c8f1eb8ceff 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)