From f1b4b713a2d75587faf0b3b2394de4b1ed1975b4 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Tue, 30 Dec 2014 12:30:11 +0100 Subject: [PATCH] pdns_control make it posible to notify all zones at once --- docs/markdown/authoritative/internals.md | 2 +- pdns/dynhandler.cc | 28 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/markdown/authoritative/internals.md b/docs/markdown/authoritative/internals.md index 2c3639e267..60ef514b39 100644 --- a/docs/markdown/authoritative/internals.md +++ b/docs/markdown/authoritative/internals.md @@ -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. diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 87522b4bd6..79c5f42895 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -266,15 +266,35 @@ string DLNotifyHostHandler(const vector&parts, Utility::pid_t ppid) string DLNotifyHandler(const vector&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< domains; + B.getAllDomains(&domains); + + int total = 0; + int notified = 0; + for (vector::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&parts, Utility::pid_t ppid) -- 2.47.2