From: bert hubert Date: Sun, 27 Sep 2015 18:58:29 +0000 (+0200) Subject: further round of DNSName cleanup. Found more cases where we were round-tripping DNSNa... X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~28^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b873e23a12ef280261bd382c449dc73dde182f1f;p=thirdparty%2Fpdns.git further round of DNSName cleanup. Found more cases where we were round-tripping DNSNames accidentally too. --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 80536026f1..c4baaced34 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -507,7 +507,7 @@ string Bind2Backend::DLReloadNowHandler(const vector&parts, Utility::pid for(vector::const_iterator i=parts.begin()+1;i&parts, Utility::pid if(parts.size() > 1) { for(vector::const_iterator i=parts.begin()+1;istartTransaction("", -1); + sd.db->startTransaction(DNSName(""), -1); bool realrr=true; uint32_t maxent = ::arg().asNum("max-ent-entries"); @@ -369,12 +369,12 @@ void dbBench(const std::string& fname) dt.set(); unsigned int hits=0, misses=0; for(; n < 10000; ++n) { - const string& domain = domains[random() % domains.size()]; + DNSName domain(domains[random() % domains.size()]); B.lookup(QType(QType::NS), domain); while(B.get(rr)) { hits++; } - B.lookup(QType(QType::A), boost::lexical_cast(random())+"."+domain); + B.lookup(QType(QType::A), DNSName(boost::lexical_cast(random()))+domain); while(B.get(rr)) { } misses++; @@ -546,9 +546,9 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone) cout<<"[Warning] DNSKEY record not at apex '"<startTransaction("", -1); + sd.db->startTransaction(DNSName(), -1); if (! sd.db->replaceRRSet(sd.domain_id, zone, rr.qtype, rrs)) { sd.db->abortTransaction(); @@ -893,10 +893,10 @@ bool testAlgorithms() return DNSCryptoKeyEngine::testAll(); } -void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int cores) +void testSpeed(DNSSECKeeper& dk, const DNSName& zone, const string& remote, int cores) { DNSResourceRecord rr; - rr.qname="blah."+zone; + rr.qname=DNSName("blah")+zone; rr.qtype=QType::A; rr.ttl=3600; rr.auth=1; @@ -910,7 +910,7 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c throw runtime_error("No backends available for DNSSEC key storage"); } - ChunkedSigningPipe csp(zone, 1, remote, cores); + ChunkedSigningPipe csp(DNSName(zone), 1, remote, cores); vector signatures; uint32_t rnd; @@ -925,7 +925,7 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c rr.content=tmp; snprintf(tmp, sizeof(tmp), "r-%u", rnd); - rr.qname=string(tmp)+"."+zone; + rr.qname=DNSName(tmp)+zone; if(csp.submit(rr)) while(signatures = csp.getChunk(), !signatures.empty()) @@ -1251,11 +1251,11 @@ void testSchema(DNSSECKeeper& dk, const DNSName& zone) db->feedRecord(rr); rr.qtype=QType::A; - rr.qname="_underscore."+zone; + rr.qname=DNSName("_underscore")+zone; rr.content="127.0.0.1"; db->feedRecord(rr); - rr.qname="bla."+zone; + rr.qname=DNSName("bla")+zone; cout<<"Committing"<commitTransaction(); @@ -1265,9 +1265,9 @@ void testSchema(DNSSECKeeper& dk, const DNSName& zone) rectifyZone(dk, zone); cout<<"Checking underscore ordering"<getBeforeAndAfterNames(di.id, zone, "z."+zone, before, after); + db->getBeforeAndAfterNames(di.id, zone, DNSName("z")+zone, before, after); cout<<"got '"< 1 ? cmds[1] : ""); @@ -1493,7 +1494,7 @@ try cerr << "Syntax: pdnssec test-speed numcores [signing-server]"< 3) ? cmds[3] : "", atoi(cmds[2].c_str())); + testSpeed(dk, DNSName(cmds[1]), (cmds.size() > 3) ? cmds[3] : "", atoi(cmds[2].c_str())); } else if(cmds[0] == "verify-crypto") { if(cmds.size() != 2) { @@ -1508,15 +1509,14 @@ try cerr << "Syntax: pdnssec show-zone ZONE"< mustRectify; + vector mustRectify; dk.startTransaction(); unsigned int zoneErrors=0; for(unsigned int n = 1; n < cmds.size(); ++n) { - const string& zone=cmds[n]; + DNSName zone(cmds[n]); if(secureZone(dk, zone)) { mustRectify.push_back(zone); } else { @@ -1672,7 +1672,7 @@ try } dk.commitTransaction(); - BOOST_FOREACH(string& zone, mustRectify) + for(const auto& zone : mustRectify) rectifyZone(dk, zone); if (zoneErrors) { @@ -1746,7 +1746,7 @@ try cerr<<"Syntax: pdnssec set-presigned ZONE"<convertToISC() < keys; DomainInfo di; @@ -2155,7 +2155,7 @@ try cerr << "Syntax: " << cmds[0] << " zone kind [value value ..]" << endl; return 1; } - string zone = cmds[1]; + DNSName zone(cmds[1]); string kind = cmds[2]; vector meta(cmds.begin() + 3, cmds.end()); diff --git a/pdns/zone2json.cc b/pdns/zone2json.cc index af3a4504f7..8b2e814994 100644 --- a/pdns/zone2json.cc +++ b/pdns/zone2json.cc @@ -173,7 +173,7 @@ try obj["name"] = i->name.toStringNoDot(); while(zpt.get(rr)) - recs.push_back(emitRecord(i->name.toStringNoDot(), rr.qname.toStringNoDot(), rr.qtype.getName(), rr.content, rr.ttl)); + recs.push_back(emitRecord(i->name.toStringNoDot(), rr.qname, rr.qtype.getName(), rr.content, rr.ttl)); obj["records"] = recs; Json tmp = obj; cout<name != "." && i->name != "localhost" && i->name != "0.0.127.in-addr.arpa" ) + if( i->name != DNSName(".") && i->name != DNSName("localhost") && i->name != DNSName("0.0.127.in-addr.arpa") ) { cerr << "Parsing file: " << i->filename << ", domain: " << i->name.toString() << endl; g_zonename = i->name; @@ -229,8 +229,8 @@ int main( int argc, char* argv[] ) return 1; } - g_zonename = args["zone-name"]; - ZoneParserTNG zpt(args["zone-file"], args["zone-name"]); + g_zonename = DNSName(args["zone-name"]); + ZoneParserTNG zpt(args["zone-file"], g_zonename); DNSResourceRecord rr; while(zpt.get(rr)) callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl); diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index 9f6b6ab9db..512a953c52 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -407,7 +407,7 @@ try if(rr.qtype.getCode() == QType::SOA) seenSOA=true; - emitRecord(i->name.toStringNoDot(), rr.qname.toStringNoDot(), rr.qtype.getName(), rr.content, rr.ttl, comment); + emitRecord(i->name.toStringNoDot(), rr.qname, rr.qtype.getName(), rr.content, rr.ttl, comment); } num_domainsdone++; } @@ -431,11 +431,11 @@ try cerr<<"\r100% done\033\133\113"<