From: bert hubert Date: Thu, 5 Nov 2015 19:53:59 +0000 (+0100) Subject: make speedtest work again X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8a514bbfefcdbe96ad6c5560dac01ce05cbe5fe;p=pdns make speedtest work again --- diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 6c9bc9f07..fdf52c027 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -497,27 +497,6 @@ struct NegCacheEntry struct timeval d_now; -static bool magicAddrMatch(const QType& query, const QType& answer) -{ - if(query.getCode() != QType::ADDR) - return false; - return answer.getCode() == QType::A || answer.getCode() == QType::AAAA; -} - - -bool moreSpecificThan(const string& a, const string &b) -{ - static string dot("."); - int counta=(a!=dot), countb=(b!=dot); - - for(string::size_type n=0;ncountb; -} struct ParsePacketTest @@ -554,129 +533,6 @@ struct ParsePacketTest lwr.d_result.push_back(rr); } - - - - // reap all answers from this packet that are acceptable - for(vector::iterator i=lwr.d_result.begin();i != lwr.d_result.end();++i) { - if(i->qtype.getCode() == QType::OPT) { - // <qname<<"' from '"<qname<<"|"<qtype.getName()<<"|"<content<<"' from '"<qtype.getCode()==QType::ANY) { - // LOG<<"NO! - we don't accept 'ANY' data"<qname, auth)) { - if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && i->d_place==DNSResourceRecord::ANSWER && 0) { - // LOG<<"NO! Is from delegation-only zone"<ttl=min(s_maxcachettl, i->ttl); - - DNSResourceRecord rr=*i; - rr.d_place=DNSResourceRecord::ANSWER; - - // rr.ttl += d_now.tv_sec; - - 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; - } - - // RC.replace(d_now.tv_sec, i->first.first, i->first.second, i->second, lwr.d_aabit); - } - set nsset; - // LOG< ret; - QType qtype(QType::A); - string auth("."); - - for(vector::const_iterator i=lwr.d_result.begin();i!=lwr.d_result.end();++i) { - if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && - lwr.d_rcode==RCode::NXDomain) { - // LOG<qname; - ne.d_ttd=d_now.tv_sec + min(i->ttl, 3600U); // controversial - ne.d_name=qname; - ne.d_qtype=QType(0); // this encodes 'whole record' - - { - // Lock l(&s_negcachelock); - // replacing_insert(s_negcache, ne); - } - } - else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { - ret.push_back(*i); - newtarget=i->content; - } - // for ANY answers we *must* have an authoritative answer - 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) ) ) - ) - ) - { - - // LOG<content<<"|"<qtype.getName()<<"'"<d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { - if(moreSpecificThan(i->qname,auth)) { - newauth=i->qname; - // LOG<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<content); - } - else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && - lwr.d_rcode==RCode::NoError) { - // LOG<qtype.getName()+"'") <qname; - ne.d_ttd=d_now.tv_sec + i->ttl; - ne.d_name=qname; - ne.d_qtype=qtype; - if(qtype.getCode()) { // prevents us from blacking out a whole domain - // Lock l(&s_negcachelock); - // replacing_insert(s_negcache, ne); - } - } - } } const vector& d_packet; @@ -741,6 +597,34 @@ struct VectorExpandTest }; +struct DNSNameParseTest +{ + string getName() const + { + return "DNSName parse"; + } + + void operator()() const + { + DNSName name("www.powerdns.com"); + } + +}; + +struct DNSNameRootTest +{ + string getName() const + { + return "DNSName root"; + } + + void operator()() const + { + DNSName name("."); + } + +}; + struct IEqualsTest @@ -918,6 +802,9 @@ try doRun(VStringtokTest()); doRun(StringAppendTest()); + doRun(DNSNameParseTest()); + doRun(DNSNameRootTest()); + cerr<<"Total runs: " << g_totalRuns<