]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add list-zone capability to pdns_control
authorRuben d'Arco <cyclops@prof-x.net>
Mon, 5 Nov 2012 17:02:03 +0000 (18:02 +0100)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 7 Mar 2014 07:26:36 +0000 (08:26 +0100)
pdns/dynhandler.cc
pdns/dynhandler.hh [changed mode: 0644->0755]
pdns/receiver.cc [changed mode: 0644->0755]

index 308b87aae25725b0cf874f7018d96f324863dd56..8c85569e447d27dacf79a1e09636fb4e111befd7 100644 (file)
@@ -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();
+}
old mode 100644 (file)
new mode 100755 (executable)
index 80f9ee7..ce13125
@@ -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 */
old mode 100644 (file)
new mode 100755 (executable)
index 61a9f91..83155f2
@@ -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")));