From: Pieter Lexis Date: Mon, 22 Jun 2015 11:04:59 +0000 (+0200) Subject: Whitespace fixes for pdns/syncres.cc X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~77^2~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=710af846f69b1e9ec986ceb0e7732f491fc98282;p=thirdparty%2Fpdns.git Whitespace fixes for pdns/syncres.cc --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index be0777e9db..db5993f2a6 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -3,7 +3,7 @@ Copyright (C) 2003 - 2014 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 as published + it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation Additionally, the license of this program contains a special @@ -80,8 +80,8 @@ bool SyncRes::s_noEDNS; SyncRes::SyncRes(const struct timeval& now) : d_outqueries(0), d_tcpoutqueries(0), d_throttledqueries(0), d_timeouts(0), d_unreachables(0), d_totUsec(0), d_now(now), d_cacheonly(false), d_nocache(false), d_doEDNS0(false), d_lm(s_lm) - -{ + +{ if(!t_sstorage) { t_sstorage = new StaticStorage(); } @@ -91,10 +91,10 @@ SyncRes::SyncRes(const struct timeval& now) : d_outqueries(0), d_tcpoutqueries( int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qclass, vector&ret) { s_queries++; - - if( (qtype.getCode() == QType::AXFR)) + + if( (qtype.getCode() == QType::AXFR)) return -1; - + if( (qtype.getCode()==QType::PTR && pdns_iequals(qname, "1.0.0.127.in-addr.arpa.")) || (qtype.getCode()==QType::A && qname.length()==10 && pdns_iequals(qname, "localhost."))) { ret.clear(); @@ -112,7 +112,7 @@ int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qcla } if(qclass==QClass::CHAOS && qtype.getCode()==QType::TXT && - (pdns_iequals(qname, "version.bind.") || pdns_iequals(qname, "id.server.") || pdns_iequals(qname, "version.pdns.") ) + (pdns_iequals(qname, "version.bind.") || pdns_iequals(qname, "id.server.") || pdns_iequals(qname, "version.pdns.") ) ) { ret.clear(); DNSResourceRecord rr; @@ -127,12 +127,12 @@ int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qcla ret.push_back(rr); return 0; } - + if(qclass==QClass::ANY) qclass=QClass::IN; else if(qclass!=QClass::IN) return -1; - + set beenthere; int res=doResolve(qname, qtype, ret, 0, beenthere); return res; @@ -191,7 +191,7 @@ bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vectorfirst) && chopOffDotted(wcarddomain)) { LOG(prefix<second.d_records.equal_range(boost::make_tuple("*."+wcarddomain)); + range=iter->second.d_records.equal_range(boost::make_tuple("*."+wcarddomain)); if(range.first==range.second) continue; @@ -211,7 +211,7 @@ bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vectorfirst)) { - range=iter->second.d_records.equal_range(boost::make_tuple(nsdomain,QType(QType::NS))); + range=iter->second.d_records.equal_range(boost::make_tuple(nsdomain,QType(QType::NS))); if(range.first==range.second) continue; @@ -221,7 +221,7 @@ bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vectorsecond.d_records.find(boost::make_tuple(authdomain, QType(QType::SOA))); if(ziter!=iter->second.d_records.end()) { @@ -233,7 +233,7 @@ bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vectord_pingCorrect && res->d_haveEDNS) + else if(!res->d_pingCorrect && res->d_haveEDNS) mode = EDNSStatus::EDNSPINGOK; else if(res->d_pingCorrect) { L<modeSetAt=d_now.tv_sec; - // cerr<<"Result: ret="<d_haveEDNS<<", EDNS-PING correct: "<d_pingCorrect<<", new mode: "<d_haveEDNS<<", EDNS-PING correct: "<d_pingCorrect<<", new mode: "< SyncRes::getAddrs(const string &qname, int depth, set cset; if(t_RC->get(d_now.tv_sec, qname, QType(QType::AAAA), &cset) > 0) { for(set::const_iterator k=cset.begin();k!=cset.end();++k) { - if(k->ttl > (unsigned int)d_now.tv_sec ) { + if(k->ttl > (unsigned int)d_now.tv_sec ) { ret.push_back(ComboAddress(k->content, 53)); } } @@ -510,7 +510,7 @@ vector SyncRes::getAddrs(const string &qname, int depth, set 1) { random_shuffle(ret.begin(), ret.end(), dns_random); @@ -518,7 +518,7 @@ vector SyncRes::getAddrs(const string &qname, int depth, setnsSpeeds.find(qname); if(best != t_sstorage->nsSpeeds.end()) - for(ret_t::iterator i=ret.begin(); i != ret.end(); ++i) { + for(ret_t::iterator i=ret.begin(); i != ret.end(); ++i) { if(*i==best->second.d_best) { // got the fastest one if(i!=ret.begin()) { *i=*ret.begin(); @@ -548,7 +548,7 @@ void SyncRes::getBestNSFromCache(const string &qname, const QType& qtype, setget(d_now.tv_sec, subdomain, QType(QType::NS), &ns) > 0) { for(set::const_iterator k=ns.begin();k!=ns.end();++k) { - if(k->ttl > (unsigned int)d_now.tv_sec ) { + if(k->ttl > (unsigned int)d_now.tv_sec ) { set aset; DNSResourceRecord rr=*k; @@ -596,8 +596,8 @@ void SyncRes::getBestNSFromCache(const string &qname, const QType& qtype, setdomainmap->find(*qname); - if(ret!=t_sstorage->domainmap->end()) + if(ret!=t_sstorage->domainmap->end()) break; }while(chopOffDotted(*qname)); return ret; @@ -619,7 +619,7 @@ string SyncRes::getBestNSNamesFromCache(const string &qname, const QType& qtype, { string subdomain(qname); string authdomain(qname); - + domainmap_t::const_iterator iter=getBestAuthZone(&authdomain); if(iter!=t_sstorage->domainmap->end()) { if( iter->second.d_servers.empty() ) @@ -647,7 +647,7 @@ bool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector< { string prefix; if(doLog()) { - prefix=d_prefix; + prefix=d_prefix; prefix.append(depth, ' '); } @@ -656,14 +656,14 @@ bool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector< res=RCode::ServFail; return true; } - + LOG(prefix< cset; if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME),&cset) > 0) { for(set::const_iterator j=cset.begin();j!=cset.end();++j) { if(j->ttl>(unsigned int) d_now.tv_sec) { - LOG(prefix<content<<"'"<content<<"'"<&ret, int depth, int &res) { bool giveNegative=false; - + string prefix; if(doLog()) { prefix=d_prefix; @@ -708,21 +708,21 @@ bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector "< range; QType qtnull(0); - - if(s_rootNXTrust && - (range.first=t_sstorage->negcache.find(tie(getLastLabel(qname), qtnull))) != t_sstorage->negcache.end() && + + if(s_rootNXTrust && + (range.first=t_sstorage->negcache.find(tie(getLastLabel(qname), qtnull))) != t_sstorage->negcache.end() && range.first->d_qname=="." && (uint32_t)d_now.tv_sec < range.first->d_ttd ) { sttl=range.first->d_ttd - d_now.tv_sec; - + LOG(prefix<d_name<<"' & '"<d_qname<<"' for another "<d_qname; sqt=QType::SOA; moveCacheItemToBack(t_sstorage->negcache, range.first); - + giveNegative=true; } else { @@ -740,7 +740,7 @@ bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vectord_qname<<"' for another "<d_qname; @@ -778,7 +778,7 @@ bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector SyncRes::shuffleInSpeedOrder(set random_shuffle(rnameservers.begin(),rnameservers.end(), dns_random); speedOrder so(speeds); stable_sort(rnameservers.begin(),rnameservers.end(), so); - + if(doLog()) { LOG(prefix<<"Nameservers: "); for(vector::const_iterator i=rnameservers.begin();i!=rnameservers.end();++i) { @@ -856,9 +856,9 @@ struct TCacheComp { if(pdns_ilexicographical_compare(a.first, b.first)) return true; - if(pdns_ilexicographical_compare(b.first, a.first)) + if(pdns_ilexicographical_compare(b.first, a.first)) return false; - + return a.second < b.second; } }; @@ -871,8 +871,8 @@ static bool magicAddrMatch(const QType& query, const QType& answer) } /** returns -1 in case of no results, rcode otherwise */ -int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, - vector&ret, +int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, + vector&ret, int depth, set&beenthere) { string prefix; @@ -880,13 +880,13 @@ int SyncRes::doResolveAt(set nameservers, string auth, prefix=d_prefix; prefix.append(depth, ' '); } - + LOG(prefix< rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname+": ") : string() ); - - for(vector::const_iterator tns=rnameservers.begin();;++tns) { + + for(vector::const_iterator tns=rnameservers.begin();;++tns) { if(tns==rnameservers.end()) { LOG(prefix< nameservers, string auth, return -1; } // this line needs to identify the 'self-resolving' behaviour, but we get it wrong now - if(pdns_iequals(qname, *tns) && qtype.getCode()==QType::A && rnameservers.size() > (unsigned)(1+1*s_doIPv6)) { + if(pdns_iequals(qname, *tns) && qtype.getCode()==QType::A && rnameservers.size() > (unsigned)(1+1*s_doIPv6)) { LOG(prefix< nameservers, string auth, txtAddr=txtAddr.c_str()+1; } ComboAddress addr=parseIPAndPort(txtAddr, 53); - + remoteIPs.push_back(addr); pierceDontQuery=true; } @@ -958,7 +958,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { LOG(prefix<toStringWithPort() <<", asking '"<throttle.shouldThrottle(d_now.tv_sec, boost::make_tuple(*remoteIP, "", 0))) { LOG(prefix< nameservers, string auth, LOG(prefix<match(&*remoteIP)) { LOG(prefix<toString() << ", blocked by 'dont-query' setting" << endl); s_dontqueries++; @@ -982,15 +982,15 @@ int SyncRes::doResolveAt(set nameservers, string auth, LOG(prefix<toStringWithPort() < s_maxtotusec) + + if(s_maxtotusec && d_totUsec > s_maxtotusec) throw ImmediateServFailException("Too much time waiting for "+qname+"|"+qtype.getName()+", timeouts: "+boost::lexical_cast(d_timeouts) +", throttles: "+boost::lexical_cast(d_throttledqueries) + ", queries: "+lexical_cast(d_outqueries)+", "+lexical_cast(d_totUsec/1000)+"msec"); if(d_pdl && d_pdl->preoutquery(*remoteIP, d_requestor, qname, qtype, lwr.d_result, resolveret)) { LOG(prefix< nameservers, string auth, s_unreachables++; d_unreachables++; LOG(prefix<nsSpeeds[*tns].submit(*remoteIP, 1000000, &d_now); // 1 sec - + // code below makes sure we don't filter COM or the root if (s_serverdownmaxfails > 0 && (auth.find('.')+1 != auth.size()) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) { LOG(prefix<toString() <<". Going full throttle for 1 minute" < nameservers, string auth, t_sstorage->throttle.throttle(d_now.tv_sec,boost::make_tuple(*remoteIP, qname, qtype.getCode()),60,3); // servfail or refused continue; } - + if(s_serverdownmaxfails > 0) t_sstorage->fails.clear(*remoteIP); @@ -1044,10 +1044,10 @@ int SyncRes::doResolveAt(set nameservers, string auth, t_sstorage->throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, qname, qtype.getCode()), 60, 100); // lame } } - + if(remoteIP == remoteIPs.end()) // we tried all IP addresses, none worked - continue; - + continue; + if(lwr.d_tcbit) { if(!doTCP) { doTCP=true; @@ -1057,7 +1057,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, LOG(prefix<toString() <<"), rcode="< nameservers, string auth, LOG("YES!"<ttl=min(s_maxcachettl, i->ttl); - + DNSResourceRecord rr=*i; rr.d_place=DNSResourceRecord::ANSWER; @@ -1123,38 +1123,38 @@ int SyncRes::doResolveAt(set nameservers, string auth, if(rr.qtype.getCode() == QType::NS) // people fiddle with the case rr.content=toLower(rr.content); // this must stay! (the cache can't be case-insensitive on the RHS of records) - + tcache[make_pair(i->qname,i->qtype)].insert(rr); } - } + } else LOG("NO!"<second.size() > 1) { // need to group the ttl to be the minimum of the RRSET (RFC 2181, 5.2) uint32_t lowestTTL=std::numeric_limits::max(); for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) lowestTTL=min(lowestTTL, j->ttl); - + for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) ((tcache_t::value_type::second_type::value_type*)&(*j))->ttl=lowestTTL; } t_RC->replace(d_now.tv_sec, i->first.first, i->first.second, i->second, lwr.d_aabit); } - set nsset; + set nsset; LOG(prefix<d_place==DNSResourceRecord::AUTHORITY && i->qtype.getCode()==QType::SOA && + if(i->d_place==DNSResourceRecord::AUTHORITY && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NXDomain && dottedEndsOn(qname,i->qname) && dottedEndsOn(i->qname, auth)) { LOG(prefix<ttl = min(i->ttl, s_maxnegttl); if(!newtarget.length()) // only add a SOA if we're not going anywhere after this ret.push_back(*i); @@ -1162,18 +1162,18 @@ int SyncRes::doResolveAt(set nameservers, string auth, NegCacheEntry ne; ne.d_qname=i->qname; - + ne.d_ttd=d_now.tv_sec + i->ttl; - + ne.d_name=qname; ne.d_qtype=QType(0); // this encodes 'whole record' - + replacing_insert(t_sstorage->negcache, ne); if(s_rootNXTrust && auth==".") { ne.d_name = getLastLabel(ne.d_name); replacing_insert(t_sstorage->negcache, ne); } - + negindic=true; } else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { @@ -1181,32 +1181,32 @@ int SyncRes::doResolveAt(set nameservers, string auth, newtarget=i->content; } // for ANY answers we *must* have an authoritative answer, unless we are forwarding recursively - else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && + else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && ( i->qtype==qtype || (lwr.d_aabit && (qtype==QType(QType::ANY) || magicAddrMatch(qtype, i->qtype) ) ) || sendRDQuery - ) - ) + ) + ) { - + LOG(prefix<content<<"|"<qtype.getName()<<"'"<d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { + else if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { if(moreSpecificThan(i->qname,auth)) { newauth=i->qname; LOG(prefix<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<content); } - else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && + else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NoError) { LOG(prefix< nameservers, string auth, } } - if(done){ + if(done){ LOG(prefix< nameservers, string auth, LOG(prefix<