From f6ef9d7b68f75fdb0e7516c3b4b47c114ea7749c Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Sun, 3 Aug 2008 17:59:15 +0000 Subject: [PATCH] implement get-parameter as suggested by Wouter de Jong of WideXS git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1243 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/docs/pdns.sgml | 8 ++++++++ pdns/rec_channel_rec.cc | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index 040592729e..b519eac8a2 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -7949,6 +7949,14 @@ local0.err /var/log/pdns.err + + get-parameter parameter1 parameter2 ../term> + + + Retrieve a configuration parameter. All parameters from the configuration and command line can be queried. + + + ping diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index c33088c9c1..57c8e6cf2b 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -10,11 +10,13 @@ #include #include #include +#include #include #include #include #include "logger.hh" #include "dnsparser.hh" +#include "arguments.hh" #ifndef WIN32 #include #include @@ -69,6 +71,26 @@ string doGet(T begin, T end) return ret; } +template +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 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"; -- 2.47.2