]> granicus.if.org Git - pdns/commitdiff
if you really want to run the json interface to the recursor, you can now do so by...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 18 Nov 2012 19:13:31 +0000 (19:13 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 18 Nov 2012 19:13:31 +0000 (19:13 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2904 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/json_ws.cc
pdns/pdns_recursor.cc

index 91c56525dceb984cad72756cbd7c43fcf850c67a..5210cab6bf23d5227e300cbb5287a865d5438ee1 100644 (file)
@@ -129,7 +129,7 @@ void JWebserver::readRequest(int fd)
     content += returnJSONObject(stats);  
   }
   else if(varmap["command"]=="log-grep") {
-    content += makeLogGrepJSON(varmap, "/var/log/pdns.log", " pdns_recursor[");
+    content += makeLogGrepJSON(varmap, ::arg()["logfile"], " pdns_recursor[");
   }
   else { //  if(varmap["command"] == "stats") {
     stats = getAllStatsMap();
index cb1527ea32512c0eb25d5263c6ee8a40d89a2fa0..479f80f80002452a2e26aa1236e1b95be437ce34 100644 (file)
@@ -26,7 +26,7 @@
 #endif // WIN32
 
 #include <boost/foreach.hpp>
-
+#include "json_ws.hh"
 #include <pthread.h>
 #include "recpacketcache.hh"
 #include "utility.hh" 
@@ -1832,8 +1832,13 @@ try
   PacketID pident;
 
   t_fdm=getMultiplexer();
-  if(!t_id) 
+  if(!t_id) {
+    if(::arg().mustDo("json-interface")) {
+      L<<Logger::Warning << "Enabling JSON interface" << endl;
+      new JWebserver(t_fdm);
+    }
     L<<Logger::Error<<"Enabled '"<< t_fdm->getName() << "' multiplexer"<<endl;
+  }
 
   t_fdm->addReadFD(g_pipes[t_id].readToThread, handlePipeRequest);
 
@@ -1968,8 +1973,9 @@ int main(int argc, char **argv)
     ::arg().setSwitch( "ntservice", "Run as service" )= "no";
     ::arg().setSwitch( "use-ntlog", "Use the NT logging facilities" )= "yes"; 
     ::arg().setSwitch( "use-logfile", "Use a log file" )= "no"; 
-    ::arg().setSwitch( "logfile", "Filename of the log file" )= "recursor.log"; 
 #else
+    ::arg().set( "logfile", "Filename of the log file for JSON parser" )= "/var/log/pdns.log"; 
+    ::arg().setSwitch( "json-interface", "If we should run a JSON webserver") = "no";
     ::arg().set("quiet","Suppress logging of questions and answers")="";
     ::arg().set("logging-facility","Facility to log messages as. 0 corresponds to local0")="";
 #endif