]> granicus.if.org Git - pdns/commitdiff
second batch of non-behaviour changing changes (we hope)
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 22 Jun 2008 20:04:09 +0000 (20:04 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 22 Jun 2008 20:04:09 +0000 (20:04 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1216 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/packethandler.cc
pdns/receiver.cc

index 6ba69a92b0f9767a22e64cc86b2e11b9fbed4c45..1ccf6c3ea87fdb39d9bb5962641c10f77334e9db 100644 (file)
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 #include "utility.hh"
 #include <string>
 #include <sys/types.h>
@@ -45,12 +46,12 @@ extern string s_programname;
 PacketHandler::PacketHandler():B(s_programname)
 {
   s_count++;
-  d_doFancyRecords = (arg()["fancy-records"]!="no");
-  d_doWildcards = (arg()["wildcards"]!="no");
-  d_doCNAME = (arg()["skip-cname"]=="no");
-  d_doRecursion= arg().mustDo("recursor");
-  d_logDNSDetails= arg().mustDo("log-dns-details");
-  d_doIPv6AdditionalProcessing = arg().mustDo("do-ipv6-additional-processing");
+  d_doFancyRecords = (::arg()["fancy-records"]!="no");
+  d_doWildcards = (::arg()["wildcards"]!="no");
+  d_doCNAME = (::arg()["skip-cname"]=="no");
+  d_doRecursion= ::arg().mustDo("recursor");
+  d_logDNSDetails= ::arg().mustDo("log-dns-details");
+  d_doIPv6AdditionalProcessing = ::arg().mustDo("do-ipv6-additional-processing");
 }
 
 DNSBackend *PacketHandler::getBackend()
@@ -84,7 +85,7 @@ void PacketHandler::addRootReferral(DNSPacket* r)
     r->addRecord(rr);
   }
 
-  if(boost::iequals(arg()["send-root-referral"], "lean"))
+  if(boost::iequals(::arg()["send-root-referral"], "lean"))
      return;
 
   // add the additional stuff
@@ -118,7 +119,7 @@ int PacketHandler::findMboxFW(DNSPacket *p, DNSPacket *r, string &target)
 
   if(wedoforward) {
     r->clearRecords();
-    rr.content=arg()["smtpredirector"];
+    rr.content=::arg()["smtpredirector"];
     rr.priority=25;
     rr.ttl=7200;
     rr.qtype=QType::MX;
@@ -143,7 +144,7 @@ int PacketHandler::findUrl(DNSPacket *p, DNSPacket *r, string &target)
       r->clearRecords();
     found=true;
     DLOG(L << "Found a URL!" << endl);
-    rr.content=arg()["urlredirector"];
+    rr.content=::arg()["urlredirector"];
     rr.qtype=QType::A; 
     rr.qname=target;
          
@@ -162,7 +163,7 @@ int PacketHandler::findUrl(DNSPacket *p, DNSPacket *r, string &target)
       r->clearRecords();
     found=true;
     DLOG(L << "Found a CURL!" << endl);
-    rr.content=arg()["urlredirector"];
+    rr.content=::arg()["urlredirector"];
     rr.qtype=1; // A
     rr.qname=target;
     rr.ttl=300;
@@ -212,7 +213,7 @@ int PacketHandler::doVersionRequest(DNSPacket *p, DNSPacket *r, string &target)
   DNSResourceRecord rr;
   
   // modes: anonymous, powerdns only, full, spoofed
-  const string mode=arg()["version-string"];
+  const string mode=::arg()["version-string"];
   if(p->qtype.getCode()==QType::TXT && target=="version.bind") {// TXT
     if(mode.empty() || mode=="full") 
       rr.content="Served by POWERDNS "VERSION" $Id$";
@@ -279,7 +280,7 @@ int PacketHandler::doWildcardRecords(DNSPacket *p, DNSPacket *r, string &target)
        rr.qname=target;
 
        if(d_doFancyRecords && p->qtype.getCode()==QType::ANY && (rr.qtype.getCode()==QType::URL || rr.qtype.getCode()==QType::CURL)) {
-         rr.content=arg()["urlredirector"];
+         rr.content=::arg()["urlredirector"];
          rr.qtype=QType::A; 
        }
 
@@ -297,8 +298,8 @@ int PacketHandler::doWildcardRecords(DNSPacket *p, DNSPacket *r, string &target)
          retargeted=true;
        }
       }
-      else if(d_doFancyRecords && arg().mustDo("wildcard-url") && p->qtype.getCode()==QType::A && rr.qtype.getName()=="URL") {
-       rr.content=arg()["urlredirector"];
+      else if(d_doFancyRecords && ::arg().mustDo("wildcard-url") && p->qtype.getCode()==QType::A && rr.qtype.getName()=="URL") {
+       rr.content=::arg()["urlredirector"];
        rr.qtype=QType::A; 
        rr.qname=target;
        
@@ -351,7 +352,7 @@ int PacketHandler::doAdditionalProcessingAndDropAA(DNSPacket *p, DNSPacket *r)
        bool foundOne=false;
        while(B.get(rr)) {
          foundOne=true;
-         if(rr.domain_id!=i->domain_id && arg()["out-of-zone-additional-processing"]=="no") {
+         if(rr.domain_id!=i->domain_id && ::arg()["out-of-zone-additional-processing"]=="no") {
            DLOG(L<<Logger::Warning<<"Not including out-of-zone additional processing of "<<i->qname<<" ("<<rr.qname<<")"<<endl);
            continue; // not adding out-of-zone additional data
          }
@@ -489,7 +490,7 @@ int PacketHandler::processNotify(DNSPacket *p)
      We determine the SOA at our (known) master
      if master is higher -> do stuff
   */
-  if(!arg().mustDo("slave")) {
+  if(!::arg().mustDo("slave")) {
     L<<Logger::Error<<"Received NOTIFY for "<<p->qdomain<<" from "<<p->getRemote()<<" but slave support is disabled in the configuration"<<endl;
     return RCode::NotImp;
   }
@@ -502,7 +503,7 @@ int PacketHandler::processNotify(DNSPacket *p)
   }
     
   string authServer(p->getRemote());
-  if(arg().contains("trusted-notification-proxy", p->getRemote())) {
+  if(::arg().contains("trusted-notification-proxy", p->getRemote())) {
     L<<Logger::Error<<"Received NOTIFY for "<<p->qdomain<<" from trusted-notification-proxy "<< p->getRemote()<<endl;
     if(di.masters.empty()) {
       L<<Logger::Error<<"However, "<<p->qdomain<<" does not have any masters defined"<<endl;
@@ -601,14 +602,14 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     // XXX FIXME do this in DNSPacket::parse ?
 
     if(!validDNSName(p->qdomain)) {
-      if(arg().mustDo("log-dns-details"))
+      if(::arg().mustDo("log-dns-details"))
         L<<Logger::Error<<"Received a malformed qdomain from "<<p->getRemote()<<", '"<<p->qdomain<<"': dropping"<<endl;
       S.inc("corrupt-packets");
       return 0;
     }
     if(p->d.opcode) { // non-zero opcode (again thanks RA!)
       if(p->d.opcode==Opcode::Update) {
-       if(arg().mustDo("log-failed-updates"))
+       if(::arg().mustDo("log-failed-updates"))
          L<<Logger::Notice<<"Received an UPDATE opcode from "<<p->getRemote()<<" for "<<p->qdomain<<", sending NOTIMP"<<endl;
        r=p->replyPacket(); 
        r->setRcode(RCode::NotImp); // notimp;
@@ -733,7 +734,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
          DLOG(L<<"Found a direct answer: "<<rr.content<<endl);
          found=true;
          if(d_doFancyRecords && p->qtype.getCode()==QType::ANY && (rr.qtype.getCode()==QType::URL || rr.qtype.getCode()==QType::CURL)) {
-           rr.content=arg()["urlredirector"];
+           rr.content=::arg()["urlredirector"];
            rr.qtype=QType::A; 
            rr.qname=target;
          }
@@ -781,7 +782,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     int zoneId;
     zoneId=-1;
     
-    if(p->d.rd && d_doRecursion && arg().mustDo("allow-recursion-override"))
+    if(p->d.rd && d_doRecursion && ::arg().mustDo("allow-recursion-override"))
       weAuth=getAuth(p, &sd, target, &zoneId);
     else
       weAuth=false;
@@ -815,7 +816,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
            p->getRemote()<< (p->d.rd ? " (recursion was desired)" : "") <<endl;
 
        r->setA(false);
-       if(arg().mustDo("send-root-referral")) {
+       if(::arg().mustDo("send-root-referral")) {
          DLOG(L<<Logger::Warning<<"Adding root-referral"<<endl);
          addRootReferral(r);
        }
index 001dc72737b2f99699f4098e9003dfe4002b763e..8ab7038c8121bb01a53cf463cb2f7d345b23e052 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2007  PowerDNS.COM BV
+    Copyright (C) 2002 - 2008  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2
@@ -16,6 +16,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
+#include "packetcache.hh"
 
 #include <cstdio>
 #include <signal.h>
@@ -51,7 +52,6 @@
 #include "packethandler.hh"
 #include "statbag.hh"
 #include "tcpreceiver.hh"
-#include "packetcache.hh"
 #include "ws.hh"
 #include "misc.hh"
 #include "dynlistener.hh"
@@ -123,7 +123,7 @@ static void takedown(int i)
 
 static void writePid(void)
 {
-  string fname=arg()["socket-dir"]+"/"+s_programname+".pid";
+  string fname=::arg()["socket-dir"]+"/"+s_programname+".pid";
   ofstream of(fname.c_str());
   if(of)
     of<<getpid()<<endl;
@@ -204,9 +204,9 @@ static int guardian(int argc, char **argv)
       char **const newargv=new char*[argc+2];
       int n;
 
-      if(arg()["config-name"]!="") {
-       progname+="-"+arg()["config-name"];
-       L<<Logger::Error<<"Virtual configuration name: "<<arg()["config-name"]<<endl;
+      if(::arg()["config-name"]!="") {
+       progname+="-"+::arg()["config-name"];
+       L<<Logger::Error<<"Virtual configuration name: "<<::arg()["config-name"]<<endl;
       }
 
       newargv[0]=strdup(const_cast<char *>((progname+"-instance").c_str()));
@@ -321,35 +321,35 @@ static int guardian(int argc, char **argv)
 static void UNIX_declareArguments()
 {
   static char pietje[128]="!@@SYSCONFDIR@@:";
-  arg().set("config-dir","Location of configuration directory (pdns.conf)")=
+  ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=
     strcmp(pietje+1,"@@SYSCONFDIR@@:") ? pietje+strlen("@@SYSCONFDIR@@:")+1 : SYSCONFDIR;
   
-  arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
-  arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
-  arg().set("module-dir","Default directory for modules")=LIBDIR;
-  arg().set("chroot","If set, chroot to this directory for more security")="";
-  arg().set("logging-facility","Log under a specific facility")="";
-  arg().set("daemon","Operate as a daemon")="no";
+  ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
+  ::arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
+  ::arg().set("module-dir","Default directory for modules")=LIBDIR;
+  ::arg().set("chroot","If set, chroot to this directory for more security")="";
+  ::arg().set("logging-facility","Log under a specific facility")="";
+  ::arg().set("daemon","Operate as a daemon")="no";
 
 }
 
 static void loadModules()
 {
-  if(!arg()["load-modules"].empty()) { 
+  if(!::arg()["load-modules"].empty()) { 
     vector<string>modules;
     
-    stringtok(modules,arg()["load-modules"],",");
+    stringtok(modules,::arg()["load-modules"],",");
     
     for(vector<string>::const_iterator i=modules.begin();i!=modules.end();++i) {
       bool res;
       const string &module=*i;
       
       if(module.find(".")==string::npos)
-       res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so");
+       res=UeberBackend::loadmodule(::arg()["module-dir"]+"/lib"+module+"backend.so");
       else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.'))    // absolute or current path
        res=UeberBackend::loadmodule(module);
       else
-       res=UeberBackend::loadmodule(arg()["module-dir"]+"/"+module);
+       res=UeberBackend::loadmodule(::arg()["module-dir"]+"/"+module);
       
       if(res==false) {
        L<<Logger::Error<<"receiver unable to load module "<<module<<endl;
@@ -405,38 +405,38 @@ int main(int argc, char **argv)
     declareArguments();
     UNIX_declareArguments();
       
-    arg().laxParse(argc,argv); // do a lax parse
+    ::arg().laxParse(argc,argv); // do a lax parse
     
-    if(arg()["config-name"]!="") 
-      s_programname+="-"+arg()["config-name"];
+    if(::arg()["config-name"]!="") 
+      s_programname+="-"+::arg()["config-name"];
     
     (void)theL(s_programname);
     
-    string configname=arg()["config-dir"]+"/"+s_programname+".conf";
+    string configname=::arg()["config-dir"]+"/"+s_programname+".conf";
     cleanSlashes(configname);
 
-    if(!arg().mustDo("config") && !arg().mustDo("no-config")) // "config" == print a configuration file
-      arg().laxFile(configname.c_str());
+    if(!::arg().mustDo("config") && !::arg().mustDo("no-config")) // "config" == print a configuration file
+      ::arg().laxFile(configname.c_str());
     
-    arg().laxParse(argc,argv); // reparse so the commandline still wins
-    if(!arg()["logging-facility"].empty()) {
-      boost::optional<int> val=logFacilityToLOG(arg().asNum("logging-facility") );
+    ::arg().laxParse(argc,argv); // reparse so the commandline still wins
+    if(!::arg()["logging-facility"].empty()) {
+      boost::optional<int> val=logFacilityToLOG(::arg().asNum("logging-facility") );
       if(val)
        theL().setFacility(*val);
       else
-       L<<Logger::Error<<"Unknown logging facility "<<arg().asNum("logging-facility") <<endl;
+       L<<Logger::Error<<"Unknown logging facility "<<::arg().asNum("logging-facility") <<endl;
     }
 
-    L.setLoglevel((Logger::Urgency)(arg().asNum("loglevel")));
-    L.toConsole((Logger::Urgency)(arg().asNum("loglevel")));  
+    L.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
+    L.toConsole((Logger::Urgency)(::arg().asNum("loglevel")));  
 
-    if(arg().mustDo("help") || arg().mustDo("config")) {
-      arg().set("daemon")="no";
-      arg().set("guardian")="no";
+    if(::arg().mustDo("help") || ::arg().mustDo("config")) {
+      ::arg().set("daemon")="no";
+      ::arg().set("guardian")="no";
     }
 
-    if(arg().mustDo("guardian") && !isGuarded(argv)) {
-      if(arg().mustDo("daemon")) {
+    if(::arg().mustDo("guardian") && !isGuarded(argv)) {
+      if(::arg().mustDo("daemon")) {
        L.toConsole(Logger::Critical);
        daemonize();
       }
@@ -445,7 +445,7 @@ int main(int argc, char **argv)
       cerr<<"Um, we did get here!"<<endl;
     }
 
-    if(arg().mustDo("version")) {
+    if(::arg().mustDo("version")) {
       cerr<<"Version: "VERSION", compiled on "<<__DATE__", "__TIME__;
 #ifdef __GNUC__ 
       cerr<<" with gcc version "<<__VERSION__;
@@ -457,27 +457,27 @@ int main(int argc, char **argv)
     // we really need to do work - either standalone or as an instance
     
     loadModules();
-    BackendMakers().launch(arg()["launch"]); // vrooooom!
+    BackendMakers().launch(::arg()["launch"]); // vrooooom!
 
-    if(!arg().getCommands().empty()) {
+    if(!::arg().getCommands().empty()) {
       cerr<<"Fatal: non-option on the command line, perhaps a '--setting=123' statement missed the '='?"<<endl;
       exit(99);
     }
 
 
     
-    if(arg().mustDo("help")) {
+    if(::arg().mustDo("help")) {
       cerr<<"syntax:"<<endl<<endl;
-      cerr<<arg().helpstring(arg()["help"])<<endl;
+      cerr<<::arg().helpstring(::arg()["help"])<<endl;
       exit(99);
     }
     
-    if(arg().mustDo("config")) {
-      cout<<arg().configstring()<<endl;
+    if(::arg().mustDo("config")) {
+      cout<<::arg().configstring()<<endl;
       exit(99);
     }
 
-    if(arg().mustDo("list-modules")) {
+    if(::arg().mustDo("list-modules")) {
       vector<string>modules=BackendMakers().getModules();
       cerr<<"Modules available:"<<endl;
       for(vector<string>::const_iterator i=modules.begin();i!=modules.end();++i)
@@ -486,7 +486,7 @@ int main(int argc, char **argv)
       exit(99);
     }
 
-    if(!arg().asNum("local-port")) {
+    if(!::arg().asNum("local-port")) {
       L<<Logger::Error<<"Unable to launch, binding to no port or port 0 makes no sense"<<endl;
       exit(99); // this isn't going to fix itself either
     }
@@ -494,7 +494,7 @@ int main(int argc, char **argv)
       L<<Logger::Error<<"Unable to launch, no backends configured for querying"<<endl;
       exit(99); // this isn't going to fix itself either
     }    
-    if(arg().mustDo("daemon")) {
+    if(::arg().mustDo("daemon")) {
       L.toConsole(Logger::None);
       if(!isGuarded(argv))
        daemonize();
@@ -507,7 +507,7 @@ int main(int argc, char **argv)
     else {
       L<<Logger::Warning<<"This is a standalone pdns"<<endl; 
       
-      if(arg().mustDo("control-console"))
+      if(::arg().mustDo("control-console"))
        dl=new DynListener();
       else
        dl=new DynListener(s_programname);
@@ -530,13 +530,13 @@ int main(int argc, char **argv)
 
     
     // reparse, with error checking
-    if(!arg().mustDo("no-config"))
-      arg().file(configname.c_str());
-    arg().parse(argc,argv);
+    if(!::arg().mustDo("no-config"))
+      ::arg().file(configname.c_str());
+    ::arg().parse(argc,argv);
     UeberBackend::go();
     N=new UDPNameserver; // this fails when we are not root, throws exception
     
-    if(!arg().mustDo("disable-tcp"))
+    if(!::arg().mustDo("disable-tcp"))
       TN=new TCPNameserver; 
   }
   catch(const ArgException &A) {
@@ -563,12 +563,12 @@ int main(int argc, char **argv)
     mainthread();
   }
   catch(AhuException &AE) {
-    if(!arg().mustDo("daemon"))
+    if(!::arg().mustDo("daemon"))
       cerr<<"Exiting because: "<<AE.reason<<endl;
     L<<Logger::Error<<"Exiting because: "<<AE.reason<<endl;
   }      
   catch(exception &e) {
-    if(!arg().mustDo("daemon"))
+    if(!::arg().mustDo("daemon"))
       cerr<<"Exiting because of STL error: "<<e.what()<<endl;
     L<<Logger::Error<<"Exiting because of STL error: "<<e.what()<<endl;
   }