From e8d78143d410e14e1f546631ce8ffca1a5d5ec9f Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Sun, 22 Jun 2008 20:04:09 +0000 Subject: [PATCH] second batch of non-behaviour changing changes (we hope) git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1216 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/packethandler.cc | 45 ++++++++++--------- pdns/receiver.cc | 102 +++++++++++++++++++++--------------------- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 6ba69a92b..1ccf6c3ea 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -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 #include @@ -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<qname<<" ("< do stuff */ - if(!arg().mustDo("slave")) { + if(!::arg().mustDo("slave")) { L<qdomain<<" from "<getRemote()<<" but slave support is disabled in the configuration"<getRemote()); - if(arg().contains("trusted-notification-proxy", p->getRemote())) { + if(::arg().contains("trusted-notification-proxy", p->getRemote())) { L<qdomain<<" from trusted-notification-proxy "<< p->getRemote()<qdomain<<" does not have any masters defined"<qdomain)) { - if(arg().mustDo("log-dns-details")) + if(::arg().mustDo("log-dns-details")) L<getRemote()<<", '"<qdomain<<"': dropping"<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<getRemote()<<" for "<qdomain<<", sending NOTIMP"<replyPacket(); r->setRcode(RCode::NotImp); // notimp; @@ -733,7 +734,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse) DLOG(L<<"Found a direct answer: "<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)" : "") <setA(false); - if(arg().mustDo("send-root-referral")) { + if(::arg().mustDo("send-root-referral")) { DLOG(L< #include @@ -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<((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()) { vectormodules; - stringtok(modules,arg()["load-modules"],","); + stringtok(modules,::arg()["load-modules"],","); for(vector::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< val=logFacilityToLOG(arg().asNum("logging-facility") ); + ::arg().laxParse(argc,argv); // reparse so the commandline still wins + if(!::arg()["logging-facility"].empty()) { + boost::optional val=logFacilityToLOG(::arg().asNum("logging-facility") ); if(val) theL().setFacility(*val); else - L<