From: Christian Hofstaedtler Date: Fri, 7 Oct 2016 15:17:49 +0000 (+0200) Subject: Fixup pdnsutil X-Git-Tag: rec-4.1.0-alpha1~253^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d83581f86d392ce6423a5880492723732f962edf;p=thirdparty%2Fpdns.git Fixup pdnsutil --- diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index f8fbbb94f5..55fd82fc1a 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -353,7 +353,7 @@ void dbBench(const std::string& fname) domains.push_back("powerdns.com"); int n=0; - DNSResourceRecord rr; + DNSZoneRecord rr; DTime dt; dt.set(); unsigned int hits=0, misses=0; @@ -439,10 +439,10 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vect SOAData sd_p; if(B.getSOAUncached(parent, sd_p)) { bool ns=false; - DNSResourceRecord rr; + DNSZoneRecord zr; B.lookup(QType(QType::ANY), zone, NULL, sd_p.domain_id); - while(B.get(rr)) - ns |= (rr.qtype == QType::NS); + while(B.get(zr)) + ns |= (zr.dr.d_type == QType::NS); if (!ns) { cout<<"[Error] No delegation for zone '"<list(zone, di.id); pre.clear(); post.clear(); - DNSResourceRecord rr; { if(tmpfd < 0 && (tmpfd=open(tmpnam, O_WRONLY | O_TRUNC, 0600)) < 0) unixDie("Error reopening temporary file "+string(tmpnam)); string header("; Warning - every name in this file is ABSOLUTE!\n$ORIGIN .\n"); if(write(tmpfd, header.c_str(), header.length()) < 0) unixDie("Writing zone to temporary file"); + DNSResourceRecord rr; while(di.backend->get(rr)) { if(!rr.qtype.getCode()) continue; @@ -1000,6 +1000,7 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) { } cmdline.clear(); ZoneParserTNG zpt(tmpnam, g_rootdnsname); + DNSResourceRecord rr; map, vector > grouped; while(zpt.get(rr)) { try { @@ -1018,7 +1019,7 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) { checkrr.clear(); for(const DNSRecord& rr : post) { - DNSResourceRecord drr(rr); + DNSResourceRecord drr = DNSResourceRecord::fromWire(rr); drr.domain_id = di.id; checkrr.push_back(drr); } @@ -1084,7 +1085,7 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) { for(const auto& c : changed) { vector vrr; for(const DNSRecord& rr : grouped[c.first]) { - DNSResourceRecord drr(rr); + DNSResourceRecord drr = DNSResourceRecord::fromWire(rr); drr.domain_id = di.id; vrr.push_back(drr); } @@ -1254,9 +1255,9 @@ int addOrReplaceRecord(bool addOrReplace, const vector& cmds) { rr.qname = name; DNSResourceRecord oldrr; if(addOrReplace) { // the 'add' case - B.lookup(rr.qtype, rr.qname, 0, di.id); + di.backend->lookup(rr.qtype, rr.qname, 0, di.id); - while(B.get(oldrr)) + while(di.backend->get(oldrr)) newrrs.push_back(oldrr); } @@ -1269,11 +1270,11 @@ int addOrReplaceRecord(bool addOrReplace, const vector& cmds) { else rr.ttl = ::arg().asNum("default-ttl"); } - B.lookup(QType(QType::ANY), rr.qname, 0, di.id); + di.backend->lookup(QType(QType::ANY), rr.qname, 0, di.id); bool found=false; if(rr.qtype.getCode() == QType::CNAME) { // this will save us SO many questions - while(B.get(oldrr)) { + while(di.backend->get(oldrr)) { if(addOrReplace || oldrr.qtype.getCode() != QType::CNAME) // the replace case is ok if we replace one CNAME by the other found=true; } @@ -1283,7 +1284,7 @@ int addOrReplaceRecord(bool addOrReplace, const vector& cmds) { } } else { - while(B.get(oldrr)) { + while(di.backend->get(oldrr)) { if(oldrr.qtype.getCode() == QType::CNAME) found=true; } @@ -1389,7 +1390,6 @@ void testSpeed(DNSSECKeeper& dk, const DNSName& zone, const string& remote, int rr.ttl=3600; rr.auth=1; rr.qclass = QClass::IN; - rr.d_place=DNSResourceRecord::ANSWER; UeberBackend db("key-only"); @@ -1621,12 +1621,12 @@ bool showZone(DNSSECKeeper& dk, const DNSName& zone, bool exportDS = false) // get us some keys vector keys; - DNSResourceRecord rr; + DNSZoneRecord zr; B.lookup(QType(QType::DNSKEY), zone); - while(B.get(rr)) { - if (rr.qtype != QType::DNSKEY) continue; - keys.push_back(DNSKEYRecordContent(rr.getZoneRepresentation())); + while(B.get(zr)) { + if (zr.dr.d_type != QType::DNSKEY) continue; + keys.push_back(*getRR(zr.dr)); } if(keys.empty()) {