]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add --config-name to recursor
authorRuben d'Arco <cyclops@prof-x.net>
Fri, 16 Aug 2013 18:41:25 +0000 (20:41 +0200)
committerRuben d'Arco <cyclops@prof-x.net>
Fri, 16 Aug 2013 18:41:25 +0000 (20:41 +0200)
This adds --config-name to pdns_recursor and rec_control.
Changed s_programname to recursor as that makes the logic more like pdns_server and is useful.
The rec_control has been updated as well so we can still query the correct recursor

pdns/pdns_recursor.cc
pdns/rec_control.cc
pdns/win32_pdns_recursor.cc

index f48900486680691018fe0b8dbaf801a2c5fcbf11..fb95f7bb80fc28ed0a11a50b10d50a7981267660 100644 (file)
@@ -109,7 +109,7 @@ static __thread NetmaskGroup* t_allowFrom;
 static NetmaskGroup* g_initialAllowFrom; // new thread needs to be setup with this
 
 NetmaskGroup* g_dontQuery;
-string s_programname="pdns_recursor";
+string s_programname="recursor";
 
 typedef vector<int> tcpListenSockets_t;
 tcpListenSockets_t g_tcpListenSockets;   // shared across threads, but this is fine, never written to from a thread. All threads listen on all sockets
@@ -695,7 +695,7 @@ void startDoResolve(void *p)
 
 void makeControlChannelSocket(int processNum=-1)
 {
-  string sockname=::arg()["socket-dir"]+"/pdns_recursor";
+  string sockname=::arg()["socket-dir"]+"/"+s_programname;
   if(processNum >= 0)
     sockname += "."+lexical_cast<string>(processNum);
   sockname+=".controlsocket";
@@ -1669,7 +1669,9 @@ void parseACLs()
 
 int serviceMain(int argc, char*argv[])
 {
-  L.setName("pdns_recursor");
+
+
+  L.setName(s_programname);
 
   L.setLoglevel((Logger::Urgency)(6)); // info and up
 
@@ -2027,6 +2029,7 @@ int main(int argc, char **argv)
     ::arg().set("network-timeout", "Wait this nummer of milliseconds for network i/o")="1500";
     ::arg().set("threads", "Launch this number of threads")="2";
     ::arg().set("processes", "Launch this number of processes (EXPERIMENTAL, DO NOT CHANGE)")="1";
+    ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
 #ifdef WIN32
     ::arg().set("quiet","Suppress logging of questions and answers")="off";
     ::arg().setSwitch( "register-service", "Register the service" )= "no";
@@ -2092,13 +2095,17 @@ int main(int argc, char **argv)
     L.toConsole(Logger::Info);
     ::arg().laxParse(argc,argv); // do a lax parse
 
+    if(::arg()["config-name"]!="") 
+      s_programname+="-"+::arg()["config-name"];
+
+
     if(::arg().mustDo("config")) {
       cout<<::arg().configstring()<<endl;
       exit(0);
     }
 
 
-    string configname=::arg()["config-dir"]+"/recursor.conf";
+    string configname=::arg()["config-dir"]+"/"+s_programname+".conf";
     cleanSlashes(configname);
 
     if(!::arg().file(configname.c_str())) 
index 47abfde4eb408721a9cb64f8ce20b4428b19f808..852b2bb03c2ce5bb57d0a692b4343669b36ed0de 100644 (file)
@@ -41,6 +41,7 @@ static void initArguments(int argc, char** argv)
   arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
   arg().set("process","When controlling multiple recursors, the target process number")="";
   arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5";
+  arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
   arg().setCmd("help","Provide this helpful message");
 
   arg().laxParse(argc,argv);  
@@ -49,7 +50,11 @@ static void initArguments(int argc, char** argv)
     cerr<<arg().helpstring(arg()["help"])<<endl;
     exit(99);
   }
+
   string configname=::arg()["config-dir"]+"/recursor.conf";
+  if (::arg()["config-name"] != "")
+    configname=::arg()["config-dir"]+"/recursor-"+::arg()["config-name"]+".conf";
+  
   cleanSlashes(configname);
 
   if(!::arg().preParseFile(configname.c_str(), "socket-dir", LOCALSTATEDIR)) 
@@ -62,7 +67,11 @@ try
 {
   initArguments(argc, argv);
   RecursorControlChannel rccS;
-  string sockname="pdns_recursor";
+  string sockname="recursor";
+
+  if (arg()["config-name"] != "")
+    sockname+="-"+arg()["config-name"];
+
   if(!arg()["process"].empty())
     sockname+="."+arg()["process"];
 
index fd79a279bff0191172849adb3ce090703ccbb5c5..c9403ef21c681ae8d13874653079905645e07a7d 100644 (file)
@@ -36,7 +36,7 @@
 #include <fstream>
 #include "recursorservice.hh"
 
-string s_programname="pdns_recursor";
+string s_programname="recursor";
 
 #ifndef WIN32
 extern "C" {