Permalink
Browse files

Add list-zone capability to pdns_control

  • Loading branch information...
1 parent 17d89a3 commit 767da1a052492217467dc802bee30c42e5c4ff08 Ruben d'Arco committed with Habbie Nov 5, 2012
Showing with 35 additions and 0 deletions.
  1. +33 −0 pdns/dynhandler.cc
  2. +1 −0 pdns/dynhandler.hh
  3. +1 −0 pdns/receiver.cc
View
@@ -32,6 +32,7 @@
#include "dnsseckeeper.hh"
#include "nameserver.hh"
#include "responsestats.hh"
+#include "ueberbackend.hh"
extern ResponseStats g_rs;
@@ -286,3 +287,35 @@ string DLReloadHandler(const vector<string>&parts, Utility::pid_t ppid)
return "Ok";
}
+string DLListZones(const vector<string>&parts, Utility::pid_t ppid)
+{
+ UeberBackend B;
+ L<<Logger::Notice<<"Received request to list domains."<<endl;
+ vector<DomainInfo> domains;
+ B.getAllDomains(&domains);
+ ostringstream ret;
+ int kindFilter = -1;
+ if (parts.size() > 1) {
+ if (toUpper(parts[1]) == "MASTER")
+ kindFilter = 0;
+ else if (toUpper(parts[1]) == "SLAVE")
+ kindFilter = 1;
+ else if (toUpper(parts[1]) == "NATIVE")
+ kindFilter = 2;
+ }
+
+ int count = 0;
+
+ for (vector<DomainInfo>::const_iterator di=domains.begin(); di != domains.end(); di++) {
+ if (di->kind == kindFilter || kindFilter == -1) {
+ ret<<di->zone<<endl;
+ count++;
+ }
+ }
+ if (kindFilter != -1)
+ ret<<parts[1]<<" zonecount:"<<count<<endl;
+ else
+ ret<<"All zonecount:"<<count<<endl;
+
+ return ret.str();
+}
View
1 pdns/dynhandler.hh 100644 → 100755
@@ -55,4 +55,5 @@ string DLVersionHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLPurgeHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLNotifyRetrieveHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid);
+string DLListZones(const vector<string>&parts, Utility::pid_t ppid);
#endif /* PDNS_DYNHANDLER_HH */
View
1 pdns/receiver.cc 100644 → 100755
@@ -578,6 +578,7 @@ int main(int argc, char **argv)
DynListener::registerFunc("SET",&DLSettingsHandler, "set config variables", "<var> <value>");
DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", "<domain>");
DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "Retrieve the current configuration");
+ DynListener::registerFunc("LIST-ZONES",&DLListZones, "Show list of zones", "[<master|slave|native>]");
if(!::arg()["tcp-control-address"].empty()) {
DynListener* dlTCP=new DynListener(ComboAddress(::arg()["tcp-control-address"], ::arg().asNum("tcp-control-port")));

0 comments on commit 767da1a

Please sign in to comment.