]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
implement get-parameter as suggested by Wouter de Jong of WideXS
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 3 Aug 2008 17:59:15 +0000 (17:59 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 3 Aug 2008 17:59:15 +0000 (17:59 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1243 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/docs/pdns.sgml
pdns/rec_channel_rec.cc

index 040592729eadd693a97355fddd662e10f3ed3304..b519eac8a22bc416324ffb87eafed59cc20f37b5 100644 (file)
@@ -7949,6 +7949,14 @@ local0.err                        /var/log/pdns.err
                </para>
              </listitem>
            </varlistentry>       
+           <varlistentry>
+             <term>get-parameter parameter1 parameter2 ../term>
+             <listitem>
+               <para>
+                 Retrieve a configuration parameter. All parameters from the configuration and command line can be queried.
+               </para>
+             </listitem>
+           </varlistentry>       
            <varlistentry>
              <term>ping</term>
              <listitem>
index c33088c9c1443b88881b0193170a465ea90e6f91..57c8e6cf2b4a9944aef464a9676b8b8267111848 100644 (file)
 #include <boost/optional.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <boost/format.hpp>
+#include <boost/algorithm/string.hpp>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "logger.hh"
 #include "dnsparser.hh"
+#include "arguments.hh"
 #ifndef WIN32
 #include <sys/resource.h>
 #include <sys/time.h>
@@ -69,6 +71,26 @@ string doGet(T begin, T end)
   return ret;
 }
 
+template<typename T>
+string doGetParameter(T begin, T end)
+{
+  string ret;
+  string parm;
+  for(T i=begin; i != end; ++i) {
+    if(::arg().parmIsset(*i)) {
+      parm=::arg()[*i];
+      replace_all(parm, "\\", "\\\\");
+      replace_all(parm, "\"", "\\\"");
+      replace_all(parm, "\n", "\\n");
+      ret += *i +"=\""+ parm +"\"\n";
+    }
+    else
+      ret += *i +" not known\n";
+  }
+  return ret;
+}
+
+
 template<typename T>
 string doDumpCache(T begin, T end)
 {
@@ -289,6 +311,10 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="get") 
     return doGet(begin, end);
 
+  if(cmd=="get-parameter") 
+    return doGetParameter(begin, end);
+
+
   if(cmd=="quit") {
     *command=&doExit;
     return "bye\n";