diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 086200f50b05..ef695a181274 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -868,7 +868,7 @@ bool LMDBBackend::get(DNSZoneRecord& zr) zr.domain_id = compoundOrdername::getDomainID(key); zr.dr.d_type = compoundOrdername::getQType(key).getCode(); zr.dr.d_ttl = lrr.ttl; - zr.dr.d_content = deserializeContentZR(zr.dr.d_type, zr.dr.d_name, lrr.content); + zr.dr.setContent(deserializeContentZR(zr.dr.d_type, zr.dr.d_name, lrr.content)); zr.auth = lrr.auth; } @@ -903,7 +903,7 @@ bool LMDBBackend::get(DNSResourceRecord& rr) rr.qname = zr.dr.d_name; rr.ttl = zr.dr.d_ttl; rr.qtype = zr.dr.d_type; - rr.content = zr.dr.d_content->getZoneRepresentation(true); + rr.content = zr.dr.getContent()->getZoneRepresentation(true); rr.domain_id = zr.domain_id; rr.auth = zr.auth; rr.disabled = zr.disabled; diff --git a/pdns/auth-catalogzone.cc b/pdns/auth-catalogzone.cc index 16d6e893ac2f..b8d825dd5de5 100644 --- a/pdns/auth-catalogzone.cc +++ b/pdns/auth-catalogzone.cc @@ -116,7 +116,7 @@ DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const DNSName& zone) dzr.dr.d_name = DNSName("version") + zone; dzr.dr.d_ttl = 0; dzr.dr.d_type = QType::TXT; - dzr.dr.d_content = std::make_shared("2"); + dzr.dr.setContent(std::make_shared("2")); return dzr; } @@ -135,14 +135,14 @@ void CatalogInfo::toDNSZoneRecords(const DNSName& zone, vector& d dzr.dr.d_name = prefix; dzr.dr.d_ttl = 0; dzr.dr.d_type = QType::PTR; - dzr.dr.d_content = std::make_shared(d_zone.toString()); + dzr.dr.setContent(std::make_shared(d_zone.toString())); dzrs.emplace_back(dzr); if (!d_coo.empty()) { dzr.dr.d_name = DNSName("coo") + prefix; dzr.dr.d_ttl = 0; dzr.dr.d_type = QType::PTR; - dzr.dr.d_content = std::make_shared(d_coo); + dzr.dr.setContent(std::make_shared(d_coo)); dzrs.emplace_back(dzr); } @@ -150,7 +150,7 @@ void CatalogInfo::toDNSZoneRecords(const DNSName& zone, vector& d dzr.dr.d_name = DNSName("group") + prefix; dzr.dr.d_ttl = 0; dzr.dr.d_type = QType::TXT; - dzr.dr.d_content = std::make_shared("\"" + group + "\""); + dzr.dr.setContent(std::make_shared("\"" + group + "\"")); dzrs.emplace_back(dzr); } } diff --git a/pdns/communicator.hh b/pdns/communicator.hh index fe4ffe4bdb3d..9cd12fcbea03 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -253,7 +253,7 @@ public: DNSZoneRecord rr; while(b->get(rr)) if(rr.dr.d_type == QType::A || rr.dr.d_type==QType::AAAA) - addresses.push_back(rr.dr.d_content->getZoneRepresentation()); // SOL if you have a CNAME for an NS + addresses.push_back(rr.dr.getContent()->getZoneRepresentation()); // SOL if you have a CNAME for an NS } return addresses; } diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 86b41c4a18d6..9d7b85a332f9 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -638,12 +638,11 @@ void DNSSECKeeper::getPreRRSIGs(UeberBackend& db, vector& rrs, ui const auto rr = *rrs.rbegin(); DNSZoneRecord dzr; - std::shared_ptr rrsig; db.lookup(QType(QType::RRSIG), !rr.wildcardname.empty() ? rr.wildcardname : rr.dr.d_name, rr.domain_id); while(db.get(dzr)) { - rrsig = getRR(dzr.dr); - if(rrsig->d_type == rr.dr.d_type) { + auto rrsig = getRR(dzr.dr); + if (rrsig->d_type == rr.dr.d_type) { if(!rr.wildcardname.empty()) { dzr.dr.d_name = rr.dr.d_name; } diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index 1a4d20f78ee3..7918199caa9d 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -157,14 +157,14 @@ struct SendReceive dr.rcode = mdp.d_header.rcode; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { if(i->first.d_place == 1 && i->first.d_type == mdp.d_qtype) - dr.ips.push_back(ComboAddress(i->first.d_content->getZoneRepresentation())); + dr.ips.push_back(ComboAddress(i->first.getContent()->getZoneRepresentation())); if(i->first.d_place == 2 && i->first.d_type == QType::SOA) { dr.seenauthsoa = true; } if(!g_quiet) { cout<first.d_place-1<<"\t"<first.d_name<<"\tIN\t"<first.d_type); - cout<<"\t"<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; + cout<<"\t"<first.d_ttl<<"\t"<< i->first.getContent()->getZoneRepresentation()<<"\n"; } } diff --git a/pdns/dnsdistdist/test-dnsdist-dnsparser.cc b/pdns/dnsdistdist/test-dnsdist-dnsparser.cc index ed7ec5a9995c..cc29a195d543 100644 --- a/pdns/dnsdistdist/test-dnsdist-dnsparser.cc +++ b/pdns/dnsdistdist/test-dnsdist-dnsparser.cc @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(test_Response) BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast(QType::CNAME)); BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN); BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, newTarget); - auto content = std::dynamic_pointer_cast(mdp.d_answers.at(0).first.d_content); + auto content = getRR(mdp.d_answers.at(0).first); BOOST_REQUIRE(content != nullptr); BOOST_CHECK_EQUAL(content->getRawContent().size(), notTheTarget.getStorage().size()); diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 9e40f6f0ad04..b9fcdfabe307 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -174,7 +174,7 @@ void DNSPacket::addRecord(DNSZoneRecord&& rr) // in case we are not compressing for AXFR, no such checking is performed! if(d_compress) { - std::string ser = const_cast(rr).dr.d_content->serialize(rr.dr.d_name); + std::string ser = rr.dr.getContent()->serialize(rr.dr.d_name); auto hash = boost::hash< std::pair >()({rr.dr.d_name, ser}); if(d_dedup.count(hash)) { // might be a dup for(auto & i : d_rrs) { @@ -354,7 +354,7 @@ void DNSPacket::wrapup(bool throwsOnTruncation) maxScopeMask = max(maxScopeMask, pos->scopeMask); pw.startRecord(pos->dr.d_name, pos->dr.d_type, pos->dr.d_ttl, pos->dr.d_class, pos->dr.d_place); - pos->dr.d_content->toPacket(pw); + pos->dr.getContent()->toPacket(pw); if(pw.size() + optsize > (d_tcp ? 65535 : getMaxReplyLen())) { if (throwsOnTruncation) { throw PDNSException("attempt to write an oversized chunk"); @@ -516,7 +516,7 @@ bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, DNSName* keyname, uint16_ for(const auto & answer : mdp.d_answers) { if(answer.first.d_type == QType::TSIG && answer.first.d_class == QType::ANY) { // cast can fail, f.e. if d_content is an UnknownRecordContent. - shared_ptr content = std::dynamic_pointer_cast(answer.first.d_content); + auto content = getRR(answer.first); if (!content) { g_log< content = std::dynamic_pointer_cast(answer.first.d_content); + auto content = getRR(answer.first); if (!content) { g_log<getZoneRepresentation(true); + rr.content = d.getContent()->getZoneRepresentation(true); rr.auth = false; rr.qclass = d.d_class; return rr; @@ -279,11 +279,11 @@ void MOADNSParser::init(bool query, const std::string_view& packet) !(d_qtype == QType::IXFR && dr.d_place == DNSResourceRecord::AUTHORITY && dr.d_type == QType::SOA) && // IXFR queries have a SOA in their AUTHORITY section (dr.d_place == DNSResourceRecord::ANSWER || dr.d_place == DNSResourceRecord::AUTHORITY || (dr.d_type != QType::OPT && dr.d_type != QType::TSIG && dr.d_type != QType::SIG && dr.d_type != QType::TKEY) || ((dr.d_type == QType::TSIG || dr.d_type == QType::SIG || dr.d_type == QType::TKEY) && dr.d_class != QClass::ANY))) { // cerr<<"discarding RR, query is "<(dr, pr); + dr.setContent(std::make_shared(dr, pr)); } else { // cerr<<"parsing RR, query is "< packet; DNSPacketWriter pw(packet, g_rootdnsname, 1); @@ -312,7 +312,9 @@ struct DNSRecord d_place(place) {} DNSName d_name; - std::shared_ptr d_content; +private: + std::shared_ptr d_content; +public: uint16_t d_type{}; uint16_t d_class{}; uint32_t d_ttl{}; @@ -331,6 +333,21 @@ struct DNSRecord return s.str(); } + void setContent(const std::shared_ptr& content) + { + d_content = content; + } + + void setContent(std::shared_ptr&& content) + { + d_content = std::move(content); + } + + [[nodiscard]] const std::shared_ptr& getContent() const + { + return d_content; + } + bool operator<(const DNSRecord& rhs) const { if(std::tie(d_name, d_type, d_class, d_ttl) < std::tie(rhs.d_name, rhs.d_type, rhs.d_class, rhs.d_ttl)) @@ -416,7 +433,7 @@ public: UnknownRecordContent(const string& zone); string getZoneRepresentation(bool noDot) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { return d_dr.d_type; @@ -486,9 +503,9 @@ bool getEDNSUDPPayloadSizeAndZ(const char* packet, size_t length, uint16_t* payl bool visitDNSPacket(const std::string_view& packet, const std::function& visitor); template -std::shared_ptr getRR(const DNSRecord& dr) +std::shared_ptr getRR(const DNSRecord& dr) { - return std::dynamic_pointer_cast(dr.d_content); + return std::dynamic_pointer_cast(dr.getContent()); } /** Simple DNSPacketMangler. Ritual is: get a pointer into the packet and moveOffset() to beyond your needs diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 179a8c9aabb7..a25691c916cd 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -252,7 +252,7 @@ void DNSProxy::mainloop() MOADNSParser mdp(false, p.getString()); // cerr<<"Got completion, "<first.d_place-1<<" "<first.d_label<<" " << DNSRecordContent::NumberToType(j->first.d_type)<<" "<first.d_content->getZoneRepresentation()<second.complete->addRecord(std::move(dzr)); } } diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index e2212e36cd69..1cf4c2c82845 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -181,13 +181,13 @@ string LUARecordContent::getCode() const } #endif -void OPTRecordContent::getData(vector >& options) +void OPTRecordContent::getData(vector >& options) const { string::size_type pos=0; uint16_t code, len; while(d_data.size() >= 4 + pos) { - code = 256 * (unsigned char)d_data[pos] + (unsigned char)d_data[pos+1]; - len = 256 * (unsigned char)d_data[pos+2] + (unsigned char)d_data[pos+3]; + code = 256 * (unsigned char)d_data.at(pos) + (unsigned char)d_data.at(pos+1); + len = 256 * (unsigned char)d_data.at(pos+2) + (unsigned char)d_data.at(pos+3); pos+=4; if(pos + len > d_data.size()) @@ -471,7 +471,7 @@ std::shared_ptr EUI48RecordContent::make(const string& zone) } return ret; } -void EUI48RecordContent::toPacket(DNSPacketWriter& pw) +void EUI48RecordContent::toPacket(DNSPacketWriter& pw) const { string blob(d_eui48, d_eui48+6); pw.xfrBlob(blob); @@ -516,7 +516,7 @@ std::shared_ptr EUI64RecordContent::make(const string& zone) } return ret; } -void EUI64RecordContent::toPacket(DNSPacketWriter& pw) +void EUI64RecordContent::toPacket(DNSPacketWriter& pw) const { string blob(d_eui64, d_eui64+8); pw.xfrBlob(blob); @@ -687,7 +687,7 @@ std::shared_ptr APLRecordContent::make(const string& zone) { // DNSRecord to Packet conversion -void APLRecordContent::toPacket(DNSPacketWriter& pw) { +void APLRecordContent::toPacket(DNSPacketWriter& pw) const { for (auto & ard : aplrdata) { pw.xfr16BitInt(ard.d_family); pw.xfr8BitInt(ard.d_prefix); @@ -859,12 +859,6 @@ static uint16_t makeTag(const std::string& data) } uint16_t DNSKEYRecordContent::getTag() const -{ - DNSKEYRecordContent tmp(*this); - return makeTag(tmp.serialize(DNSName())); // this can't be const for some reason -} - -uint16_t DNSKEYRecordContent::getTag() { return makeTag(this->serialize(DNSName())); } diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 1d3b45c5a487..dc2a1ce60048 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -41,8 +41,9 @@ static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); \ static std::shared_ptr make(const string& zonedata); \ string getZoneRepresentation(bool noDot=false) const override; \ - void toPacket(DNSPacketWriter& pw) override; \ - uint16_t getType() const override { return QType::RNAME; } \ + void toPacket(DNSPacketWriter& pw) const override; \ + uint16_t getType() const override { return QType::RNAME; } \ + template void xfrPacket(Convertor& conv, bool noDot=false) const; \ template void xfrPacket(Convertor& conv, bool noDot=false); class NAPTRRecordContent : public DNSRecordContent @@ -273,6 +274,11 @@ class ALIASRecordContent : public DNSRecordContent public: includeboilerplate(ALIAS) + [[nodiscard]] const DNSName& getContent() const + { + return d_content; + } +private: DNSName d_content; }; #endif @@ -330,7 +336,7 @@ class OPTRecordContent : public DNSRecordContent public: OPTRecordContent(){} includeboilerplate(OPT) - void getData(vector > &opts); + void getData(vector > &opts) const; private: string d_data; }; @@ -361,7 +367,6 @@ public: DNSKEYRecordContent(); includeboilerplate(DNSKEY) uint16_t getTag() const; - uint16_t getTag(); uint16_t d_flags{0}; uint8_t d_protocol{0}; @@ -668,7 +673,7 @@ public: } void fromPacket(PacketReader& pr); - void toPacket(DNSPacketWriter& pw); + void toPacket(DNSPacketWriter& pw) const; std::string getZoneRepresentation() const; static constexpr size_t const nbTypes = 65536; @@ -703,7 +708,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { return QType::NSEC; @@ -741,7 +746,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint8_t d_algorithm{0}, d_flags{0}; uint16_t d_iterations{0}; @@ -788,7 +793,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { @@ -817,7 +822,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { @@ -842,7 +847,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint8_t d_version{0}, d_size{0}, d_horizpre{0}, d_vertpre{0}; uint32_t d_latitude{0}, d_longitude{0}, d_altitude{0}; @@ -903,7 +908,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& zone); // FIXME400: DNSName& zone? string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { return QType::EUI48; } private: // storage for the bytes @@ -918,7 +923,7 @@ public: static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& zone); // FIXME400: DNSName& zone? string getZoneRepresentation(bool noDot=false) const override; - void toPacket(DNSPacketWriter& pw) override; + void toPacket(DNSPacketWriter& pw) const override; uint16_t getType() const override { return QType::EUI64; } private: // storage for the bytes @@ -1002,7 +1007,7 @@ std::shared_ptr RNAME##RecordContent::ma return std::make_shared(zonedata); \ } \ \ -void RNAME##RecordContent::toPacket(DNSPacketWriter& pw) \ +void RNAME##RecordContent::toPacket(DNSPacketWriter& pw) const \ { \ this->xfrPacket(pw); \ } \ @@ -1046,6 +1051,12 @@ void RNAME##RecordContent::xfrPacket(Convertor& conv, bool /* noDot */) \ CONV; \ if (conv.eof() == false) throw MOADNSException("When parsing " #RNAME " trailing data was not parsed: '" + conv.getRemaining() + "'"); \ } \ +template \ +void RNAME##RecordContent::xfrPacket(Convertor& conv, bool /* noDot */) const \ +{ \ + CONV; \ + if (conv.eof() == false) throw MOADNSException("When parsing " #RNAME " trailing data was not parsed: '" + conv.getRemaining() + "'"); \ +} \ struct EDNSOpts { diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 8d3a529b8e25..b713ce003e49 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -366,10 +366,10 @@ static void measureResultAndClean(qids_t::const_iterator iter) if(!g_quiet) { cout<<"orig: rcode="<::const_iterator i=canonicOrig.begin(); i!=canonicOrig.end(); ++i) - cout<<"\t"<d_name<<"\t"<d_type)<<"\t'" << (i->d_content ? i->d_content->getZoneRepresentation() : "") <<"'\n"; + cout<<"\t"<d_name<<"\t"<d_type)<<"\t'" << (i->getContent() ? i->getContent()->getZoneRepresentation() : "") <<"'\n"; cout<<"new: rcode="<::const_iterator i=canonicNew.begin(); i!=canonicNew.end(); ++i) - cout<<"\t"<d_name<<"\t"<d_type)<<"\t'" << (i->d_content ? i->d_content->getZoneRepresentation() : "") <<"'\n"; + cout<<"\t"<d_name<<"\t"<d_type)<<"\t'" << (i->getContent() ? i->getContent()->getZoneRepresentation() : "") <<"'\n"; cout<<"\n"; cout<<"-\n"; diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 50479d5ee788..f1ed8b91eb32 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -414,7 +414,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, c // zonemd: digest = hash( RR(1) | RR(2) | RR(3) | ... ), so skip RRSIG_RDATA if (includeRRSIG_RDATA) { - toHash.append(const_cast(rrc).serialize(g_rootdnsname, true, true)); + toHash.append(rrc.serialize(g_rootdnsname, true, true)); toHash.resize(toHash.size() - rrc.d_signature.length()); // chop off the end, don't sign the signature! } string nameToHash(qname.toDNSStringLC()); @@ -435,7 +435,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, c } } - for(const shared_ptr& add : signRecords) { + for (const shared_ptr& add : signRecords) { toHash.append(nameToHash); uint16_t tmp=htons(rrc.d_type); toHash.append((char*)&tmp, 2); @@ -492,7 +492,7 @@ DSRecordContent makeDSFromDNSKey(const DNSName& qname, const DNSKEYRecordContent { string toHash; toHash.assign(qname.toDNSStringLC()); - toHash.append(const_cast(drc).serialize(DNSName(), true, true)); + toHash.append(drc.serialize(DNSName(), true, true)); DSRecordContent dsrc; try { diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index f2d00f28f84c..c6ddb5bc0ec6 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -263,12 +263,12 @@ struct CanonicalCompare }; struct sharedDNSSECRecordCompare { - bool operator() (const shared_ptr& a, const shared_ptr& b) const { + bool operator() (const shared_ptr& a, const shared_ptr& b) const { return a->serialize(g_rootdnsname, true, true) < b->serialize(g_rootdnsname, true, true); } }; -typedef std::set, sharedDNSSECRecordCompare> sortedRecords_t; +typedef std::set, sharedDNSSECRecordCompare> sortedRecords_t; string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, const sortedRecords_t& signRecords, bool processRRSIGLabels = false, bool includeRRSIG_RDATA = true); diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 702e791a7db4..fae036e523bf 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -169,7 +169,7 @@ static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const DNSName& sign rr.auth=false; rr.dr.d_place = signPlace; for(RRSIGRecordContent& rrc : rrcs) { - rr.dr.d_content = std::make_shared(rrc); + rr.dr.setContent(std::make_shared(rrc)); outsigned.push_back(rr); } } @@ -236,7 +236,7 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, origTTL = pos->dr.d_ttl; signPlace = pos->dr.d_place; if(pos->auth || pos->dr.d_type == QType::DS) { - toSign.insert(pos->dr.d_content); // so ponder.. should this be a deep copy perhaps? + toSign.insert(pos->dr.getContent()); // so ponder.. should this be a deep copy perhaps? } } if(getBestAuthFromSet(authSet, signQName, signer)) diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index aef59e4dff32..9615d7c6b321 100644 --- a/pdns/ixfr.cc +++ b/pdns/ixfr.cc @@ -27,7 +27,7 @@ #include "tsigverifier.hh" vector, vector > > processIXFRRecords(const ComboAddress& primary, const DNSName& zone, - const vector& records, const std::shared_ptr& primarySOA) + const vector& records, const std::shared_ptr& primarySOA) { vector, vector > > ret; @@ -137,7 +137,7 @@ vector, vector>> getIXFRDeltas(const ComboAddr pw.getHeader()->rd=0; pw.getHeader()->id=dns_random_uint16(); pw.startRecord(zone, QType::SOA, 0, QClass::IN, DNSResourceRecord::AUTHORITY); - oursr.d_content->toPacket(pw); + oursr.getContent()->toPacket(pw); pw.commit(); TSIGRecordContent trc; @@ -193,7 +193,7 @@ vector, vector>> getIXFRDeltas(const ComboAddr // SOA WHERE THIS DELTA GOES // RECORDS TO ADD // CURRENT PRIMARY SOA - std::shared_ptr primarySOA = nullptr; + std::shared_ptr primarySOA = nullptr; vector records; size_t receivedBytes = 0; std::string reply; @@ -255,7 +255,7 @@ vector, vector>> getIXFRDeltas(const ComboAddr throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort()+"'"); } - if(sr->d_st.serial == std::dynamic_pointer_cast(oursr.d_content)->d_st.serial) { + if(sr->d_st.serial == getRR(oursr)->d_st.serial) { // we are up to date return ret; } diff --git a/pdns/ixfr.hh b/pdns/ixfr.hh index 34408e251092..bdbabd3d8db4 100644 --- a/pdns/ixfr.hh +++ b/pdns/ixfr.hh @@ -32,4 +32,4 @@ vector, vector>> getIXFRDeltas(const ComboAd const ComboAddress* laddr=0, size_t maxReceivedBytes=0); vector, vector>> processIXFRRecords(const ComboAddress& primary, const DNSName& zone, - const vector& records, const std::shared_ptr& primarySOA); + const vector& records, const std::shared_ptr& primarySOA); diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index b0485463a8f1..9207a346242a 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -124,8 +124,8 @@ struct convert { } // namespace YAML struct ixfrdiff_t { - shared_ptr oldSOA; - shared_ptr newSOA; + shared_ptr oldSOA; + shared_ptr newSOA; vector removals; vector additions; uint32_t oldSOATTL; @@ -133,7 +133,7 @@ struct ixfrdiff_t { }; struct ixfrinfo_t { - shared_ptr soa; // The SOA of the latest AXFR + shared_ptr soa; // The SOA of the latest AXFR records_t latestAXFR; // The most recent AXFR vector> ixfrDiffs; uint32_t soaTTL; @@ -227,7 +227,7 @@ static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const str } } -static void getSOAFromRecords(const records_t& records, shared_ptr& soa, uint32_t& soaTTL) { +static void getSOAFromRecords(const records_t& records, shared_ptr& soa, uint32_t& soaTTL) { for (const auto& dnsrecord : records) { if (dnsrecord.d_type == QType::SOA) { soa = getRR(dnsrecord); @@ -241,7 +241,7 @@ static void getSOAFromRecords(const records_t& records, shared_ptr& diff, const shared_ptr& fromSOA = nullptr, uint32_t fromSOATTL=0, const shared_ptr& toSOA = nullptr, uint32_t toSOATTL = 0) { +static void makeIXFRDiff(const records_t& from, const records_t& to, std::shared_ptr& diff, const shared_ptr& fromSOA = nullptr, uint32_t fromSOATTL=0, const shared_ptr& toSOA = nullptr, uint32_t toSOATTL = 0) { set_difference(from.cbegin(), from.cend(), to.cbegin(), to.cend(), back_inserter(diff->removals), from.value_comp()); set_difference(to.cbegin(), to.cend(), from.cbegin(), from.cend(), back_inserter(diff->additions), from.value_comp()); diff->oldSOA = fromSOA; @@ -282,7 +282,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint try { g_log< soa; + shared_ptr soa; uint32_t soaTTL; { string fname = workdir + "/" + domain.toString() + "/" + std::to_string(serial); @@ -330,7 +330,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint } DNSName domain = domainConfig.first; - shared_ptr current_soa; + shared_ptr current_soa; const auto& zoneInfo = getCurrentZoneInfo(domain); if (zoneInfo != nullptr) { current_soa = zoneInfo->soa; @@ -349,7 +349,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint string dir = workdir + "/" + domain.toString(); g_log< sr; + shared_ptr sr; try { zoneLastCheck = now; g_stats.incrementSOAChecks(domain); @@ -373,7 +373,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint TSIGTriplet tt; // The *new* SOA - shared_ptr soa; + shared_ptr soa; uint32_t soaTTL = 0; records_t records; try { @@ -545,7 +545,7 @@ static bool makeRefusedPacket(const MOADNSParser& mdp, vector& packet) return true; } -static vector getSOAPacket(const MOADNSParser& mdp, const shared_ptr& soa, uint32_t soaTTL) { +static vector getSOAPacket(const MOADNSParser& mdp, const shared_ptr& soa, uint32_t soaTTL) { vector packet; DNSPacketWriter pw(packet, mdp.d_qname, mdp.d_qtype); pw.getHeader()->id = mdp.d_header.id; @@ -573,7 +573,7 @@ static bool sendPacketOverTCP(int fd, const std::vector& packet) static bool addRecordToWriter(DNSPacketWriter& pw, const DNSName& zoneName, const DNSRecord& record, bool compress) { pw.startRecord(record.d_name + zoneName, record.d_type, record.d_ttl, QClass::IN, DNSResourceRecord::ANSWER, compress); - record.d_content->toPacket(pw); + record.getContent()->toPacket(pw); if (pw.size() > 16384) { pw.rollback(); return false; @@ -640,7 +640,7 @@ static bool handleAXFR(int fd, const MOADNSParser& mdp) { return false; } - shared_ptr soa = zoneInfo->soa; + shared_ptr soa = zoneInfo->soa; uint32_t soaTTL = zoneInfo->soaTTL; const records_t& records = zoneInfo->latestAXFR; @@ -665,7 +665,7 @@ static bool handleAXFR(int fd, const MOADNSParser& mdp) { /* Produces an IXFR if one can be made according to the rules in RFC 1995 and * creates a SOA or AXFR packet when required by the RFC. */ -static bool handleIXFR(int fd, const MOADNSParser& mdp, const shared_ptr& clientSOA) { +static bool handleIXFR(int fd, const MOADNSParser& mdp, const shared_ptr& clientSOA) { vector> toSend; /* we get a shared pointer of the zone info that we can't modify, ever. @@ -925,7 +925,7 @@ static void tcpWorker(int tid) { * query, but with the query type being IXFR and the authority section * containing the SOA record of client's version of the zone. */ - shared_ptr clientSOA; + shared_ptr clientSOA; for (auto &answer : mdp.d_answers) { // from dnsparser.hh: // typedef vector > answers_t; diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 292287fc33d3..4715e1dcd327 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -29,7 +29,7 @@ #include "zoneparser-tng.hh" #include "dnsparser.hh" -uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt, const uint16_t timeout) +uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt, const uint16_t timeout) { vector packet; DNSPacketWriter pw(packet, zone, QType::SOA); @@ -97,7 +97,7 @@ uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret) auto found = records.equal_range(std::tie(g_rootdnsname, t)); for(auto iter = found.first; iter != found.second; ++iter) { - auto soa = std::dynamic_pointer_cast(iter->d_content); + auto soa = getRR(*iter); if (soa) { soaret = *iter; return soa->d_st.serial; @@ -113,7 +113,7 @@ static void writeRecords(FILE* fp, const records_t& records) r.d_name.isRoot() ? "@" : r.d_name.toStringNoDot().c_str(), r.d_ttl, DNSRecordContent::NumberToType(r.d_type).c_str(), - r.d_content->getZoneRepresentation().c_str()) < 0) { + r.getContent()->getZoneRepresentation().c_str()) < 0) { throw runtime_error(stringerror()); } } @@ -187,7 +187,7 @@ void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zo * Load the zone `zone` from `fname` and put the first found SOA into `soa` * Does NOT check for nullptr */ -void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL) +void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL) { ZoneParserTNG zpt(fname, zone); zpt.disableGenerate(); diff --git a/pdns/ixfrutils.hh b/pdns/ixfrutils.hh index bce8c6b48fd9..7e31efb52dac 100644 --- a/pdns/ixfrutils.hh +++ b/pdns/ixfrutils.hh @@ -26,6 +26,7 @@ #include #include #include +#include #include "dnsparser.hh" #include "dnsrecords.hh" @@ -34,7 +35,7 @@ using namespace boost::multi_index; struct CIContentCompareStruct { - bool operator()(const shared_ptr&a, const shared_ptr& b) const + bool operator()(const shared_ptr&a, const shared_ptr& b) const { return toLower(a->getZoneRepresentation()) < toLower(b->getZoneRepresentation()); } @@ -49,15 +50,15 @@ typedef multi_index_container < member, member, member, - member, &DNSRecord::d_content> >, + BOOST_MULTI_INDEX_CONST_MEM_FUN(DNSRecord, const shared_ptr&, getContent) >, composite_key_compare, std::less, CIContentCompareStruct > > /* ordered_non_uniquw */ > /* indexed_by */ > /* multi_index_container */ records_t; -uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); +uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); uint32_t getSerialFromDir(const std::string& dir); uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret); void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory); void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone); -void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL); +void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL); diff --git a/pdns/ixplore.cc b/pdns/ixplore.cc index 90e60e505c99..e6eedf42ce2a 100644 --- a/pdns/ixplore.cc +++ b/pdns/ixplore.cc @@ -87,12 +87,12 @@ int main(int argc, char** argv) { set_difference(before.cbegin(), before.cend(), after.cbegin(), after.cend(), back_inserter(diff), before.value_comp()); for(const auto& d : diff) { - cout<<'-'<< (d.d_name+zone) <<" IN "<getZoneRepresentation()<getZoneRepresentation()<getZoneRepresentation()<getZoneRepresentation()< sr; + shared_ptr sr; uint32_t serial = getSerialFromMaster(master, zone, sr, tt); if(ourSerial == serial) { time_t sleepTime = sr ? sr->d_st.refresh : 60; @@ -199,7 +199,7 @@ int main(int argc, char** argv) { uint32_t newserial=0; for(const auto& rr : add) { if(rr.d_type == QType::SOA) { - newserial=std::dynamic_pointer_cast(rr.d_content)->d_st.serial; + newserial=getRR(rr)->d_st.serial; } } @@ -214,8 +214,8 @@ int main(int argc, char** argv) { bool stop=false; for(const auto& rr : remove) { - report<<'-'<< (rr.d_name+zone) <<" IN "<getZoneRepresentation()<getZoneRepresentation()<getZoneRepresentation()<getZoneRepresentation()<registerFunction("match", (bool (NetmaskGroup::*)(const ComboAddress&) const)&NetmaskGroup::match); // DNSRecord - d_lw->writeFunction("newDR", [](const DNSName &name, const std::string &type, unsigned int ttl, const std::string &content, int place){ QType qtype; qtype = type; auto dr = DNSRecord(); dr.d_name = name; dr.d_type = qtype.getCode(); dr.d_ttl = ttl; dr.d_content = shared_ptr(DNSRecordContent::mastermake(dr.d_type, QClass::IN, content)); dr.d_place = static_cast(place); return dr; }); + d_lw->writeFunction("newDR", [](const DNSName &name, const std::string &type, unsigned int ttl, const std::string &content, int place){ QType qtype; qtype = type; auto dr = DNSRecord(); dr.d_name = name; dr.d_type = qtype.getCode(); dr.d_ttl = ttl; dr.setContent(shared_ptr(DNSRecordContent::mastermake(dr.d_type, QClass::IN, content))); dr.d_place = static_cast(place); return dr; }); d_lw->registerMember("name", &DNSRecord::d_name); d_lw->registerMember("type", &DNSRecord::d_type); d_lw->registerMember("ttl", &DNSRecord::d_ttl); d_lw->registerMember("place", &DNSRecord::d_place); - d_lw->registerFunction("getContent", [](const DNSRecord& dr) { return dr.d_content->getZoneRepresentation(); }); + d_lw->registerFunction("getContent", [](const DNSRecord& dr) { return dr.getContent()->getZoneRepresentation(); }); d_lw->registerFunction(DNSRecord::*)()>("getCA", [](const DNSRecord& dr) { boost::optional ret; - if(auto arec = std::dynamic_pointer_cast(dr.d_content)) + if(auto arec = getRR(dr)) ret=arec->getCA(53); - else if(auto aaaarec = std::dynamic_pointer_cast(dr.d_content)) + else if(auto aaaarec = getRR(dr)) ret=aaaarec->getCA(53); return ret; }); - d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = shared_ptr(DNSRecordContent::mastermake(dr.d_type, 1, newContent)); }); + d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.setContent(shared_ptr(DNSRecordContent::mastermake(dr.d_type, 1, newContent))); }); // pdnsload d_lw->writeFunction("pdnslog", [](const std::string& msg, boost::optional loglevel) { diff --git a/pdns/nsec3dig.cc b/pdns/nsec3dig.cc index 1481e0a608f0..f47ed2c58b5e 100644 --- a/pdns/nsec3dig.cc +++ b/pdns/nsec3dig.cc @@ -171,7 +171,7 @@ try { // cerr<<"got nsec3 ["<first.d_name<<"]"<first.d_content->getZoneRepresentation()<(i->first.d_content); + const auto r = getRR(i->first); if (!r) { continue; } @@ -191,11 +191,11 @@ try if(i->first.d_type == QType::CNAME) { - namesseen.insert(DNSName(i->first.d_content->getZoneRepresentation())); + namesseen.insert(DNSName(i->first.getContent()->getZoneRepresentation())); } cout << i->first.d_place - 1 << "\t" << i->first.d_name.toString() << "\t" << i->first.d_ttl << "\tIN\t" << DNSRecordContent::NumberToType(i->first.d_type); - cout << "\t" << i->first.d_content->getZoneRepresentation() << "\n"; + cout << "\t" << i->first.getContent()->getZoneRepresentation() << "\n"; } #if 0 diff --git a/pdns/nsecrecords.cc b/pdns/nsecrecords.cc index 3bf755ed6eb5..815e3fcaac6a 100644 --- a/pdns/nsecrecords.cc +++ b/pdns/nsecrecords.cc @@ -72,7 +72,7 @@ class NSECBitmapGenerator string tmp; }; -void NSECBitmap::toPacket(DNSPacketWriter& pw) +void NSECBitmap::toPacket(DNSPacketWriter& pw) const { NSECBitmapGenerator nbg(pw); if (d_bitset) { @@ -186,7 +186,7 @@ NSECRecordContent::NSECRecordContent(const string& content, const DNSName& zone) } } -void NSECRecordContent::toPacket(DNSPacketWriter& pw) +void NSECRecordContent::toPacket(DNSPacketWriter& pw) const { pw.xfrName(d_next); d_bitmap.toPacket(pw); @@ -240,7 +240,7 @@ NSEC3RecordContent::NSEC3RecordContent(const string& content, const DNSName& zon } } -void NSEC3RecordContent::toPacket(DNSPacketWriter& pw) +void NSEC3RecordContent::toPacket(DNSPacketWriter& pw) const { pw.xfr8BitInt(d_algorithm); pw.xfr8BitInt(d_flags); @@ -306,7 +306,7 @@ NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const DN rtr.xfrHexBlob(d_salt); } -void NSEC3PARAMRecordContent::toPacket(DNSPacketWriter& pw) +void NSEC3PARAMRecordContent::toPacket(DNSPacketWriter& pw) const { pw.xfr8BitInt(d_algorithm); pw.xfr8BitInt(d_flags); @@ -366,7 +366,7 @@ CSYNCRecordContent::CSYNCRecordContent(const string& content, const DNSName& zon } } -void CSYNCRecordContent::toPacket(DNSPacketWriter& pw) +void CSYNCRecordContent::toPacket(DNSPacketWriter& pw) const { pw.xfr32BitInt(d_serial); pw.xfr16BitInt(d_flags); diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 81d157dcb620..5d603648c510 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -129,7 +129,7 @@ bool PacketHandler::addCDNSKEY(DNSPacket& p, std::unique_ptr& r) rr.auth=true; if (publishCDNSKEY == "0") { // delete DS via CDNSKEY - rr.dr.d_content=s_deleteCDNSKEYContent; + rr.dr.setContent(s_deleteCDNSKEYContent); r->addRecord(std::move(rr)); return true; } @@ -140,7 +140,7 @@ bool PacketHandler::addCDNSKEY(DNSPacket& p, std::unique_ptr& r) if (!value.second.published) { continue; } - rr.dr.d_content=std::make_shared(value.first.getDNSKEY()); + rr.dr.setContent(std::make_shared(value.first.getDNSKEY())); r->addRecord(DNSZoneRecord(rr)); haveOne=true; } @@ -177,7 +177,7 @@ bool PacketHandler::addDNSKEY(DNSPacket& p, std::unique_ptr& r) rr.dr.d_type=QType::DNSKEY; rr.dr.d_ttl=d_sd.minimum; rr.dr.d_name=p.qdomain; - rr.dr.d_content=std::make_shared(value.first.getDNSKEY()); + rr.dr.setContent(std::make_shared(value.first.getDNSKEY())); rr.auth=true; r->addRecord(std::move(rr)); haveOne=true; @@ -221,7 +221,7 @@ bool PacketHandler::addCDS(DNSPacket& p, std::unique_ptr& r) rr.auth=true; if(std::find(digestAlgos.begin(), digestAlgos.end(), "0") != digestAlgos.end()) { // delete DS via CDS - rr.dr.d_content=s_deleteCDSContent; + rr.dr.setContent(s_deleteCDSContent); r->addRecord(std::move(rr)); return true; } @@ -235,7 +235,7 @@ bool PacketHandler::addCDS(DNSPacket& p, std::unique_ptr& r) continue; } for(auto const &digestAlgo : digestAlgos){ - rr.dr.d_content=std::make_shared(makeDSFromDNSKey(p.qdomain, value.first.getDNSKEY(), pdns::checked_stoi(digestAlgo))); + rr.dr.setContent(std::make_shared(makeDSFromDNSKey(p.qdomain, value.first.getDNSKEY(), pdns::checked_stoi(digestAlgo)))); r->addRecord(DNSZoneRecord(rr)); haveOne=true; } @@ -265,7 +265,7 @@ bool PacketHandler::addNSEC3PARAM(const DNSPacket& p, std::unique_ptr rr.dr.d_ttl=d_sd.minimum; rr.dr.d_name=p.qdomain; ns3prc.d_flags = 0; // the NSEC3PARAM 'flag' is defined to always be zero in RFC5155. - rr.dr.d_content=std::make_shared(ns3prc); + rr.dr.setContent(std::make_shared(ns3prc)); rr.auth = true; r->addRecord(std::move(rr)); return true; @@ -295,7 +295,7 @@ int PacketHandler::doChaosRequest(const DNSPacket& p, std::unique_ptr } else content=mode; - rr.dr.d_content = DNSRecordContent::mastermake(QType::TXT, 1, "\""+content+"\""); + rr.dr.setContent(DNSRecordContent::mastermake(QType::TXT, 1, "\""+content+"\"")); } else if (target==idserver) { // modes: disabled, hostname or custom @@ -309,7 +309,7 @@ int PacketHandler::doChaosRequest(const DNSPacket& p, std::unique_ptr if(!tid.empty() && tid[0]!='"') { // see #6010 however tid = "\"" + tid + "\""; } - rr.dr.d_content=DNSRecordContent::mastermake(QType::TXT, 1, tid); + rr.dr.setContent(DNSRecordContent::mastermake(QType::TXT, 1, tid)); } else { r->setRcode(RCode::Refused); @@ -360,7 +360,7 @@ void PacketHandler::getBestDNAMESynth(DNSPacket& p, DNSName &target, vector(CNAMERecordContent(prefix + getRR(rr.dr)->getTarget())); + rr.dr.setContent(std::make_shared(CNAMERecordContent(prefix + getRR(rr.dr)->getTarget()))); rr.auth = false; // don't sign CNAME target = getRR(rr.dr)->getTarget(); ret.push_back(rr); @@ -420,9 +420,9 @@ bool PacketHandler::getBestWildcard(DNSPacket& p, const DNSName &target, DNSName DLOG(g_log<<"Executing Lua: '"<getCode()<<"'"<getCode(), target, d_sd.qname, d_sd.domain_id, p, rec->d_type, s_LUA); - for(const auto& r : recvec) { + for (const auto& r : recvec) { rr.dr.d_type = rec->d_type; // might be CNAME - rr.dr.d_content = r; + rr.dr.setContent(r); rr.scopeMask = p.getRealRemote().getBits(); // this makes sure answer is a specific as your question ret->push_back(rr); } @@ -553,18 +553,18 @@ void PacketHandler::doAdditionalProcessing(DNSPacket& p, std::unique_ptrdr.d_content = newRRC; if (s_SVCAutohints) { auto hints = getIPAddressFor(target, QType::A); if (hints.size() == 0) { - rrc->removeParam(SvcParam::ipv4hint); + newRRC->removeParam(SvcParam::ipv4hint); } else { - rrc->setHints(SvcParam::ipv4hint, hints); + newRRC->setHints(SvcParam::ipv4hint, hints); } } else { - rrc->removeParam(SvcParam::ipv4hint); + newRRC->removeParam(SvcParam::ipv4hint); } + rrc = newRRC; + rec->dr.setContent(std::move(newRRC)); } if (rrc->hasParam(SvcParam::ipv6hint) && rrc->autoHint(SvcParam::ipv6hint)) { @@ -572,18 +572,17 @@ void PacketHandler::doAdditionalProcessing(DNSPacket& p, std::unique_ptrdr.d_content = newRRC; if (s_SVCAutohints) { auto hints = getIPAddressFor(target, QType::AAAA); if (hints.size() == 0) { - rrc->removeParam(SvcParam::ipv6hint); + newRRC->removeParam(SvcParam::ipv6hint); } else { - rrc->setHints(SvcParam::ipv6hint, hints); + newRRC->setHints(SvcParam::ipv6hint, hints); } } else { - rrc->removeParam(SvcParam::ipv6hint); + newRRC->removeParam(SvcParam::ipv6hint); } + rec->dr.setContent(std::move(newRRC)); } } @@ -691,7 +690,7 @@ void PacketHandler::emitNSEC(std::unique_ptr& r, const DNSName& name, rr.dr.d_name = name; rr.dr.d_ttl = d_sd.getNegativeTTL(); rr.dr.d_type = QType::NSEC; - rr.dr.d_content = std::make_shared(std::move(nrc)); + rr.dr.setContent(std::make_shared(std::move(nrc))); rr.dr.d_place = (mode == 5 ) ? DNSResourceRecord::ANSWER: DNSResourceRecord::AUTHORITY; rr.auth = true; @@ -783,7 +782,7 @@ void PacketHandler::emitNSEC3(std::unique_ptr& r, const NSEC3PARAMRec rr.dr.d_name = DNSName(toBase32Hex(namehash))+d_sd.qname; rr.dr.d_ttl = d_sd.getNegativeTTL(); rr.dr.d_type=QType::NSEC3; - rr.dr.d_content=std::make_shared(std::move(n3rc)); + rr.dr.setContent(std::make_shared(std::move(n3rc))); rr.dr.d_place = (mode == 5 ) ? DNSResourceRecord::ANSWER: DNSResourceRecord::AUTHORITY; rr.auth = true; @@ -1595,9 +1594,9 @@ std::unique_ptr PacketHandler::doQuestion(DNSPacket& p) try { auto recvec=luaSynth(rec->getCode(), target, d_sd.qname, d_sd.domain_id, p, rec->d_type, s_LUA); if(!recvec.empty()) { - for(const auto& r_it : recvec) { + for (const auto& r_it : recvec) { rr.dr.d_type = rec->d_type; // might be CNAME - rr.dr.d_content = r_it; + rr.dr.setContent(r_it); rr.scopeMask = p.getRealRemote().getBits(); // this makes sure answer is a specific as your question rrset.push_back(rr); } @@ -1639,7 +1638,7 @@ std::unique_ptr PacketHandler::doQuestion(DNSPacket& p) g_log<(rr.dr)->d_content; + haveAlias=getRR(rr.dr)->getContent(); aliasScopeMask=rr.scopeMask; } diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 03da0ac20843..22fc9e48b4f9 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1208,7 +1208,7 @@ static int editZone(const DNSName &zone, const PDNSColors& col) { sort(pre.begin(), pre.end(), DNSRecord::prettyCompare); for(const auto& dr : pre) { ostringstream os; - os<getZoneRepresentation(true)<getZoneRepresentation(true)<getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <getZoneRepresentation(true) << col.rst() <& nsec) +static bool isMinimallyCoveringNSEC(const DNSName& owner, const std::shared_ptr& nsec) { /* this test only covers Cloudflare's ones (https://blog.cloudflare.com/black-lies/), we might need to cover more cases described in rfc4470 as well, but the name generation algorithm @@ -268,7 +268,7 @@ bool AggressiveNSECCache::isSmallCoveringNSEC3(const DNSName& owner, const std:: return commonPrefixIsLong(ownerHash, nextHash, AggressiveNSECCache::s_maxNSEC3CommonPrefix); } -void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner, const DNSRecord& record, const std::vector>& signatures, bool nsec3) +void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner, const DNSRecord& record, const std::vector>& signatures, bool nsec3) { if (nsec3 && nsec3Disabled()) { return; @@ -344,13 +344,13 @@ void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner, /* the TTL is already a TTD by now */ if (!nsec3 && isWildcardExpanded(owner.countLabels(), signatures.at(0))) { DNSName realOwner = getNSECOwnerName(owner, signatures); - auto pair = zoneEntry->d_entries.insert({record.d_content, signatures, std::move(realOwner), std::move(next), record.d_ttl}); + auto pair = zoneEntry->d_entries.insert({record.getContent(), signatures, std::move(realOwner), std::move(next), record.d_ttl}); if (pair.second) { ++d_entriesCount; } } else { - auto pair = zoneEntry->d_entries.insert({record.d_content, signatures, owner, std::move(next), record.d_ttl}); + auto pair = zoneEntry->d_entries.insert({record.getContent(), signatures, owner, std::move(next), record.d_ttl}); if (pair.second) { ++d_entriesCount; } @@ -433,7 +433,7 @@ bool AggressiveNSECCache::getNSEC3(time_t now, std::shared_ptr& recordSet, std::vector> signatures, const DNSName& owner, bool doDNSSEC, std::vector& ret, DNSResourceRecord::Place place = DNSResourceRecord::AUTHORITY) +static void addToRRSet(const time_t now, std::vector& recordSet, std::vector> signatures, const DNSName& owner, bool doDNSSEC, std::vector& ret, DNSResourceRecord::Place place = DNSResourceRecord::AUTHORITY) { uint32_t ttl = 0; @@ -455,7 +455,7 @@ static void addToRRSet(const time_t now, std::vector& recordSet, std: dr.d_type = QType::RRSIG; dr.d_name = owner; dr.d_ttl = ttl; - dr.d_content = std::move(signature); + dr.setContent(std::move(signature)); dr.d_place = place; dr.d_class = QClass::IN; ret.push_back(std::move(dr)); @@ -463,13 +463,13 @@ static void addToRRSet(const time_t now, std::vector& recordSet, std: } } -static void addRecordToRRSet(time_t now, const DNSName& owner, const QType& type, uint32_t ttl, std::shared_ptr& content, std::vector> signatures, bool doDNSSEC, std::vector& ret) +static void addRecordToRRSet(time_t now, const DNSName& owner, const QType& type, uint32_t ttl, std::shared_ptr& content, std::vector> signatures, bool doDNSSEC, std::vector& ret) { DNSRecord nsecRec; nsecRec.d_type = type.getCode(); nsecRec.d_name = owner; nsecRec.d_ttl = ttl; - nsecRec.d_content = std::move(content); + nsecRec.setContent(std::move(content)); nsecRec.d_place = DNSResourceRecord::AUTHORITY; nsecRec.d_class = QClass::IN; ret.push_back(std::move(nsecRec)); @@ -480,7 +480,7 @@ static void addRecordToRRSet(time_t now, const DNSName& owner, const QType& type dr.d_type = QType::RRSIG; dr.d_name = owner; dr.d_ttl = ttl; - dr.d_content = std::move(signature); + dr.setContent(std::move(signature)); dr.d_place = DNSResourceRecord::AUTHORITY; dr.d_class = QClass::IN; ret.push_back(std::move(dr)); @@ -493,7 +493,7 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& vState cachedState; std::vector wcSet; - std::vector> wcSignatures; + std::vector> wcSignatures; if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl); @@ -515,7 +515,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& vState cachedState; std::vector wcSet; - std::vector> wcSignatures; + std::vector> wcSignatures; if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl); @@ -530,7 +530,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& return true; } -bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr>& zoneEntry, std::vector& soaSet, std::vector>& soaSignatures, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, const OptLog& log) +bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr>& zoneEntry, std::vector& soaSet, std::vector>& soaSignatures, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, const OptLog& log) { DNSName zone; std::string salt; @@ -551,7 +551,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(exactNSEC3.d_record); + auto nsec3 = std::dynamic_pointer_cast(exactNSEC3.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { VLOG_NO_PREFIX(log, " but the content is not valid, or has a different salt or iterations count" << endl); return false; @@ -599,7 +599,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(closestNSEC3.d_record); + auto nsec3 = std::dynamic_pointer_cast(closestNSEC3.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { VLOG_NO_PREFIX(log, " but the content is not valid, or has a different salt or iterations count" << endl); break; @@ -656,7 +656,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(nextCloserEntry.d_record); + auto nextCloserNsec3 = std::dynamic_pointer_cast(nextCloserEntry.d_record); if (!nextCloserNsec3 || nextCloserNsec3->d_iterations != iterations || nextCloserNsec3->d_salt != salt) { VLOG(log, name << ": The NSEC3 covering the next closer is not valid, or has a different salt or iterations count, bailing out" << endl); return false; @@ -683,7 +683,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(wcEntry.d_record); + auto nsec3 = std::dynamic_pointer_cast(wcEntry.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { VLOG_NO_PREFIX(log, " but the content is not valid, or has a different salt or iterations count" << endl); return false; @@ -722,7 +722,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(wcEntry.d_record); + auto nsec3 = std::dynamic_pointer_cast(wcEntry.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { VLOG(log, name << ": The content of the NSEC3 covering the wildcard is not valid, or has a different salt or iterations count" << endl); return false; @@ -787,7 +787,7 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType vState cachedState; std::vector soaSet; - std::vector> soaSignatures; + std::vector> soaSignatures; /* we might not actually need the SOA if we find a matching wildcard, but let's not bother for now */ if (g_recCache->get(now, zone, QType::SOA, MemRecursorCache::RequireAuth, &soaSet, who, routingTag, doDNSSEC ? &soaSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { VLOG(log, name << ": No valid SOA found for " << zone << ", which is the best match for " << name << endl); @@ -809,7 +809,7 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType return false; } - auto content = std::dynamic_pointer_cast(entry.d_record); + auto content = std::dynamic_pointer_cast(entry.d_record); if (!content) { return false; } @@ -839,7 +839,7 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType VLOG_NO_PREFIX(log, ": found a possible NSEC at " << wcEntry.d_owner << " "); - auto nsecContent = std::dynamic_pointer_cast(wcEntry.d_record); + auto nsecContent = std::dynamic_pointer_cast(wcEntry.d_record); denial = matchesNSEC(wc, type.getCode(), wcEntry.d_owner, nsecContent, wcEntry.d_signatures, log); if (denial == dState::NODENIAL || denial == dState::INCONCLUSIVE) { diff --git a/pdns/recursordist/aggressive_nsec.hh b/pdns/recursordist/aggressive_nsec.hh index 46fb4cba0e54..05a3eeb3a544 100644 --- a/pdns/recursordist/aggressive_nsec.hh +++ b/pdns/recursordist/aggressive_nsec.hh @@ -53,7 +53,7 @@ public: return s_maxNSEC3CommonPrefix == 0; } - void insertNSEC(const DNSName& zone, const DNSName& owner, const DNSRecord& record, const std::vector>& signatures, bool nsec3); + void insertNSEC(const DNSName& zone, const DNSName& owner, const DNSRecord& record, const std::vector>& signatures, bool nsec3); bool getDenial(time_t, const DNSName& name, const QType& type, std::vector& ret, int& res, const ComboAddress& who, const boost::optional& routingTag, bool doDNSSEC, const OptLog& log = std::nullopt); void removeZoneInfo(const DNSName& zone, bool subzones); @@ -114,8 +114,8 @@ private: struct CacheEntry { - std::shared_ptr d_record; - std::vector> d_signatures; + std::shared_ptr d_record; + std::vector> d_signatures; DNSName d_owner; DNSName d_next; @@ -144,7 +144,7 @@ private: std::shared_ptr> getBestZone(const DNSName& zone); bool getNSECBefore(time_t now, std::shared_ptr>& zoneEntry, const DNSName& name, ZoneEntry::CacheEntry& entry); bool getNSEC3(time_t now, std::shared_ptr>& zoneEntry, const DNSName& name, ZoneEntry::CacheEntry& entry); - bool getNSEC3Denial(time_t now, std::shared_ptr>& zoneEntry, std::vector& soaSet, std::vector>& soaSignatures, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, const OptLog&); + bool getNSEC3Denial(time_t now, std::shared_ptr>& zoneEntry, std::vector& soaSet, std::vector>& soaSignatures, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, const OptLog&); bool synthesizeFromNSEC3Wildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName, const OptLog&); bool synthesizeFromNSECWildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nsec, const DNSName& wildcardName, const OptLog&); diff --git a/pdns/recursordist/filterpo.cc b/pdns/recursordist/filterpo.cc index 2d2d201a50d5..cc46516dbf61 100644 --- a/pdns/recursordist/filterpo.cc +++ b/pdns/recursordist/filterpo.cc @@ -564,7 +564,7 @@ void DNSFilterEngine::Policy::info(Logr::Priority prio, const std::shared_ptr& custom) const +DNSRecord DNSFilterEngine::Policy::getRecordFromCustom(const DNSName& qname, const std::shared_ptr& custom) const { DNSRecord dr; dr.d_name = qname; @@ -572,15 +572,15 @@ DNSRecord DNSFilterEngine::Policy::getRecordFromCustom(const DNSName& qname, con dr.d_ttl = d_ttl; dr.d_class = QClass::IN; dr.d_place = DNSResourceRecord::ANSWER; - dr.d_content = custom; + dr.setContent(custom); if (dr.d_type == QType::CNAME) { - const auto content = std::dynamic_pointer_cast(custom); + const auto content = std::dynamic_pointer_cast(custom); if (content) { DNSName target = content->getTarget(); if (target.isWildcard()) { target.chopOff(); - dr.d_content = std::make_shared(qname + target); + dr.setContent(std::make_shared(qname + target)); } } } @@ -607,15 +607,15 @@ std::vector DNSFilterEngine::Policy::getCustomRecords(const DNSName& dr.d_ttl = d_ttl; dr.d_class = QClass::IN; dr.d_place = DNSResourceRecord::ANSWER; - dr.d_content = custom; + dr.setContent(custom); if (dr.d_type == QType::CNAME) { - const auto content = std::dynamic_pointer_cast(custom); + const auto content = std::dynamic_pointer_cast(custom); if (content) { DNSName target = content->getTarget(); if (target.isWildcard()) { target.chopOff(); - dr.d_content = std::make_shared(qname + target); + dr.setContent(std::make_shared(qname + target)); } } } @@ -681,7 +681,7 @@ std::vector DNSFilterEngine::Policy::getRecords(const DNSName& qname) dr.d_ttl = static_cast(d_ttl); dr.d_type = QType::CNAME; dr.d_class = QClass::IN; - dr.d_content = DNSRecordContent::mastermake(QType::CNAME, QClass::IN, getKindToString(d_kind)); + dr.setContent(DNSRecordContent::mastermake(QType::CNAME, QClass::IN, getKindToString(d_kind))); result.push_back(std::move(dr)); } @@ -692,7 +692,7 @@ void DNSFilterEngine::Zone::dumpNamedPolicy(FILE* fp, const DNSName& name, const { auto records = pol.getRecords(name); for (const auto& dr : records) { - fprintf(fp, "%s %" PRIu32 " IN %s %s\n", dr.d_name.toString().c_str(), dr.d_ttl, QType(dr.d_type).toString().c_str(), dr.d_content->getZoneRepresentation().c_str()); + fprintf(fp, "%s %" PRIu32 " IN %s %s\n", dr.d_name.toString().c_str(), dr.d_ttl, QType(dr.d_type).toString().c_str(), dr.getContent()->getZoneRepresentation().c_str()); } } @@ -779,7 +779,7 @@ void DNSFilterEngine::Zone::dumpAddrPolicy(FILE* fp, const Netmask& nm, const DN auto records = pol.getRecords(full); for (const auto& dr : records) { - fprintf(fp, "%s %" PRIu32 " IN %s %s\n", dr.d_name.toString().c_str(), dr.d_ttl, QType(dr.d_type).toString().c_str(), dr.d_content->getZoneRepresentation().c_str()); + fprintf(fp, "%s %" PRIu32 " IN %s %s\n", dr.d_name.toString().c_str(), dr.d_ttl, QType(dr.d_type).toString().c_str(), dr.getContent()->getZoneRepresentation().c_str()); } } diff --git a/pdns/recursordist/filterpo.hh b/pdns/recursordist/filterpo.hh index 224ee3672cb7..4d11af52ccd6 100644 --- a/pdns/recursordist/filterpo.hh +++ b/pdns/recursordist/filterpo.hh @@ -108,7 +108,7 @@ public: { } - Policy(PolicyKind kind, PolicyType type, int32_t ttl = 0, std::shared_ptr data = nullptr, const std::vector>& custom = {}) : + Policy(PolicyKind kind, PolicyType type, int32_t ttl = 0, std::shared_ptr data = nullptr, const std::vector>& custom = {}) : d_custom(custom), d_zoneData(data), d_ttl(ttl), d_kind(kind), d_type(type) { } @@ -178,7 +178,7 @@ public: std::vector getCustomRecords(const DNSName& qname, uint16_t qtype) const; std::vector getRecords(const DNSName& qname) const; - std::vector> d_custom; + std::vector> d_custom; std::shared_ptr d_zoneData{nullptr}; DNSName d_trigger; string d_hit; @@ -188,7 +188,7 @@ public: PolicyType d_type; private: - DNSRecord getRecordFromCustom(const DNSName& qname, const std::shared_ptr& custom) const; + DNSRecord getRecordFromCustom(const DNSName& qname, const std::shared_ptr& custom) const; }; class Zone diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index 6358c5d84eae..df2a1bb52454 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -134,7 +134,7 @@ void RecursorLua4::DNSQuestion::addRecord(uint16_t type, const std::string& cont dr.d_ttl = ttl.get_value_or(3600); dr.d_type = type; dr.d_place = place; - dr.d_content = DNSRecordContent::mastermake(type, QClass::IN, content); + dr.setContent(DNSRecordContent::mastermake(type, QClass::IN, content)); records.push_back(dr); } @@ -281,13 +281,13 @@ void RecursorLua4::postPrepareContext() } return std::string(option.values.at(0).content, option.values.at(0).size); }); - d_lw->registerFunction("getContent", [](const DNSRecord& dr) { return dr.d_content->getZoneRepresentation(); }); + d_lw->registerFunction("getContent", [](const DNSRecord& dr) { return dr.getContent()->getZoneRepresentation(); }); d_lw->registerFunction(DNSRecord::*)()>("getCA", [](const DNSRecord& dr) { boost::optional ret; - if(auto rec = std::dynamic_pointer_cast(dr.d_content)) + if(auto rec = getRR(dr)) ret=rec->getCA(53); - else if(auto aaaarec = std::dynamic_pointer_cast(dr.d_content)) + else if(auto aaaarec = getRR(dr)) ret=aaaarec->getCA(53); return ret; }); @@ -295,7 +295,7 @@ void RecursorLua4::postPrepareContext() d_lw->registerFunction("getContent", [](const ProxyProtocolValue& value) { return value.content; }); d_lw->registerFunction("getType", [](const ProxyProtocolValue& value) { return value.type; }); - d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = DNSRecordContent::mastermake(dr.d_type, QClass::IN, newContent); }); + d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.setContent(DNSRecordContent::mastermake(dr.d_type, QClass::IN, newContent)); }); d_lw->registerFunction("addAnswer", &DNSQuestion::addAnswer); d_lw->registerFunction("addRecord", &DNSQuestion::addRecord); d_lw->registerFunction("getRecords", &DNSQuestion::getRecords); @@ -1026,7 +1026,7 @@ bool pdns_ffi_param_add_record(pdns_ffi_param_t* ref, const char* name, uint16_t dr.d_type = type; dr.d_class = QClass::IN; dr.d_place = DNSResourceRecord::Place(place); - dr.d_content = DNSRecordContent::mastermake(type, QClass::IN, std::string(content, contentSize)); + dr.setContent(DNSRecordContent::mastermake(type, QClass::IN, std::string(content, contentSize))); ref->params.records.push_back(std::move(dr)); return true; @@ -1137,12 +1137,12 @@ bool pdns_postresolve_ffi_handle_get_record(pdns_postresolve_ffi_handle_t* ref, record->name = ref->insert(std::move(name))->c_str(); } if (raw) { - auto content = ref->insert(r.d_content->serialize(r.d_name, true)); + auto content = ref->insert(r.getContent()->serialize(r.d_name, true)); record->content = content->data(); record->content_len = content->size(); } else { - auto content = ref->insert(r.d_content->getZoneRepresentation()); + auto content = ref->insert(r.getContent()->getZoneRepresentation()); record->content = content->data(); record->content_len = content->size(); } @@ -1166,10 +1166,10 @@ bool pdns_postresolve_ffi_handle_set_record(pdns_postresolve_ffi_handle_t* ref, try { DNSRecord& r = ref->handle.d_dq.currentRecords->at(i); if (raw) { - r.d_content = DNSRecordContent::deserialize(r.d_name, r.d_type, string(content, contentLen)); + r.setContent(DNSRecordContent::deserialize(r.d_name, r.d_type, string(content, contentLen))); } else { - r.d_content = DNSRecordContent::mastermake(r.d_type, QClass::IN, string(content, contentLen)); + r.setContent(DNSRecordContent::mastermake(r.d_type, QClass::IN, string(content, contentLen))); } return true; @@ -1195,10 +1195,10 @@ bool pdns_postresolve_ffi_handle_add_record(pdns_postresolve_ffi_handle_t* ref, dr.d_class = QClass::IN; dr.d_place = DNSResourceRecord::Place(place); if (raw) { - dr.d_content = DNSRecordContent::deserialize(dr.d_name, dr.d_type, string(content, contentLen)); + dr.setContent(DNSRecordContent::deserialize(dr.d_name, dr.d_type, string(content, contentLen))); } else { - dr.d_content = DNSRecordContent::mastermake(type, QClass::IN, string(content, contentLen)); + dr.setContent(DNSRecordContent::mastermake(type, QClass::IN, string(content, contentLen))); } ref->handle.d_dq.currentRecords->push_back(std::move(dr)); diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 995104351a90..77cc3e3b8ddf 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -329,16 +329,16 @@ size_t NegCache::doDump(int fd, size_t maxCacheEntries) int64_t ttl = ne.d_ttd - now.tv_sec; fprintf(fp.get(), "%s %" PRId64 " IN %s VIA %s ; (%s) origttl=%" PRIu32 " ss=%hu\n", ne.d_name.toString().c_str(), ttl, ne.d_qtype.toString().c_str(), ne.d_auth.toString().c_str(), vStateToString(ne.d_validationState).c_str(), ne.d_orig_ttl, ne.d_servedStale); for (const auto& rec : ne.authoritySOA.records) { - fprintf(fp.get(), "%s %" PRId64 " IN %s %s ; (%s)\n", rec.d_name.toString().c_str(), ttl, DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.d_content->getZoneRepresentation().c_str(), vStateToString(ne.d_validationState).c_str()); + fprintf(fp.get(), "%s %" PRId64 " IN %s %s ; (%s)\n", rec.d_name.toString().c_str(), ttl, DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.getContent()->getZoneRepresentation().c_str(), vStateToString(ne.d_validationState).c_str()); } for (const auto& sig : ne.authoritySOA.signatures) { - fprintf(fp.get(), "%s %" PRId64 " IN RRSIG %s ;\n", sig.d_name.toString().c_str(), ttl, sig.d_content->getZoneRepresentation().c_str()); + fprintf(fp.get(), "%s %" PRId64 " IN RRSIG %s ;\n", sig.d_name.toString().c_str(), ttl, sig.getContent()->getZoneRepresentation().c_str()); } for (const auto& rec : ne.DNSSECRecords.records) { - fprintf(fp.get(), "%s %" PRId64 " IN %s %s ; (%s)\n", rec.d_name.toString().c_str(), ttl, DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.d_content->getZoneRepresentation().c_str(), vStateToString(ne.d_validationState).c_str()); + fprintf(fp.get(), "%s %" PRId64 " IN %s %s ; (%s)\n", rec.d_name.toString().c_str(), ttl, DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.getContent()->getZoneRepresentation().c_str(), vStateToString(ne.d_validationState).c_str()); } for (const auto& sig : ne.DNSSECRecords.signatures) { - fprintf(fp.get(), "%s %" PRId64 " IN RRSIG %s ;\n", sig.d_name.toString().c_str(), ttl, sig.d_content->getZoneRepresentation().c_str()); + fprintf(fp.get(), "%s %" PRId64 " IN RRSIG %s ;\n", sig.d_name.toString().c_str(), ttl, sig.getContent()->getZoneRepresentation().c_str()); } } } diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 64d56f43767f..861cbc5c7a18 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -409,7 +409,7 @@ static void handleRPZCustom(const DNSRecord& spoofed, const QType& qtype, SyncRe bool oldWantsRPZ = sr.getWantsRPZ(); sr.setWantsRPZ(false); vector ans; - res = sr.beginResolve(DNSName(spoofed.d_content->getZoneRepresentation()), qtype, QClass::IN, ans); + res = sr.beginResolve(DNSName(spoofed.getContent()->getZoneRepresentation()), qtype, QClass::IN, ans); for (const auto& rec : ans) { if (rec.d_place == DNSResourceRecord::ANSWER) { ret.push_back(rec); @@ -427,7 +427,7 @@ static bool addRecordToPacket(DNSPacketWriter& pw, const DNSRecord& rec, uint32_ if (rec.d_type != QType::OPT) // their TTL ain't real minTTL = min(minTTL, rec.d_ttl); - rec.d_content->toPacket(pw); + rec.getContent()->toPacket(pw); if (pw.size() > static_cast(maxAnswerSize)) { pw.rollback(); if (rec.d_place != DNSResourceRecord::ADDITIONAL) { @@ -618,16 +618,16 @@ static bool udrCheckUniqueDNSRecord(Logr::log_t nodlogger, const DNSName& dname, if (record.d_place == DNSResourceRecord::ANSWER || record.d_place == DNSResourceRecord::ADDITIONAL) { // Create a string that represent a triplet of (qname, qtype and RR[type, name, content]) std::stringstream ss; - ss << dname.toDNSStringLC() << ":" << qtype << ":" << qtype << ":" << record.d_type << ":" << record.d_name.toDNSStringLC() << ":" << record.d_content->getZoneRepresentation(); + ss << dname.toDNSStringLC() << ":" << qtype << ":" << qtype << ":" << record.d_type << ":" << record.d_name.toDNSStringLC() << ":" << record.getContent()->getZoneRepresentation(); if (t_udrDBp && t_udrDBp->isUniqueResponse(ss.str())) { if (g_udrLog) { // This should also probably log to a dedicated file. - SLOG(g_log << Logger::Notice << "Unique response observed: qname=" << dname << " qtype=" << QType(qtype) << " rrtype=" << QType(record.d_type) << " rrname=" << record.d_name << " rrcontent=" << record.d_content->getZoneRepresentation() << endl, + SLOG(g_log << Logger::Notice << "Unique response observed: qname=" << dname << " qtype=" << QType(qtype) << " rrtype=" << QType(record.d_type) << " rrname=" << record.d_name << " rrcontent=" << record.getContent()->getZoneRepresentation() << endl, nodlogger->info(Logr::Debug, "New response observed", "qtype", Logging::Loggable(QType(qtype)), "rrtype", Logging::Loggable(QType(record.d_type)), "rrname", Logging::Loggable(record.d_name), - "rrcontent", Logging::Loggable(record.d_content->getZoneRepresentation()));); + "rrcontent", Logging::Loggable(record.getContent()->getZoneRepresentation()));); } ret = true; } @@ -712,7 +712,7 @@ int getFakeAAAARecords(const DNSName& qname, ComboAddress prefix, vector(rr)) { ComboAddress ipv4(rec->getCA()); memcpy(&prefix.sin6.sin6_addr.s6_addr[12], &ipv4.sin4.sin_addr.s_addr, sizeof(ipv4.sin4.sin_addr.s_addr)); - rr.d_content = std::make_shared(prefix); + rr.setContent(std::make_shared(prefix)); rr.d_type = QType::AAAA; } seenA = true; @@ -755,7 +755,7 @@ int getFakePTRRecords(const DNSName& qname, vector& ret) DNSRecord rr; rr.d_name = qname; rr.d_type = QType::CNAME; - rr.d_content = std::make_shared(newquery); + rr.setContent(std::make_shared(newquery)); ret.push_back(rr); auto log = g_slog->withName("dns64")->withValues("method", Logging::Loggable("getPTR")); diff --git a/pdns/recursordist/rec-lua-conf.cc b/pdns/recursordist/rec-lua-conf.cc index ce8bfb034e79..c384bd65b2d3 100644 --- a/pdns/recursordist/rec-lua-conf.cc +++ b/pdns/recursordist/rec-lua-conf.cc @@ -283,7 +283,7 @@ static void rpzPrimary(LuaConfigItems& lci, luaConfigDelayedThreads& delayedThre size_t zoneIdx; std::string dumpFile; - std::shared_ptr sr = nullptr; + std::shared_ptr sr = nullptr; try { std::string seedFile; diff --git a/pdns/recursordist/rec-lua-conf.hh b/pdns/recursordist/rec-lua-conf.hh index a357de5eb5f1..29a18b00f61a 100644 --- a/pdns/recursordist/rec-lua-conf.hh +++ b/pdns/recursordist/rec-lua-conf.hh @@ -126,7 +126,7 @@ extern GlobalStateHolder g_luaconfs; struct luaConfigDelayedThreads { // Please make sure that the tuple below only contains value types since they are used as parameters in a thread ct - std::vector, boost::optional, bool, uint32_t, size_t, TSIGTriplet, size_t, ComboAddress, uint16_t, uint32_t, std::shared_ptr, std::string>> rpzPrimaryThreads; + std::vector, boost::optional, bool, uint32_t, size_t, TSIGTriplet, size_t, ComboAddress, uint16_t, uint32_t, std::shared_ptr, std::string>> rpzPrimaryThreads; }; void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& delayedThreads, ProxyMapping&); diff --git a/pdns/recursordist/rec-protozero.cc b/pdns/recursordist/rec-protozero.cc index 3d544c1be404..e7ef18eb927e 100644 --- a/pdns/recursordist/rec-protozero.cc +++ b/pdns/recursordist/rec-protozero.cc @@ -49,50 +49,77 @@ void pdns::ProtoZero::RecMessage::addRR(const DNSRecord& record, const std::set< switch (record.d_type) { case QType::A: { - const auto& content = dynamic_cast(*(record.d_content)); - ComboAddress data = content.getCA(); + const auto& content = getRR(record); + if (!content) { + return; + } + ComboAddress data = content->getCA(); pbf_rr.add_bytes(static_cast(pdns::ProtoZero::Message::RRField::rdata), reinterpret_cast(&data.sin4.sin_addr.s_addr), sizeof(data.sin4.sin_addr.s_addr)); break; } case QType::AAAA: { - const auto& content = dynamic_cast(*(record.d_content)); - ComboAddress data = content.getCA(); + const auto& content = getRR(record); + if (!content) { + return; + } + ComboAddress data = content->getCA(); pbf_rr.add_bytes(static_cast(pdns::ProtoZero::Message::RRField::rdata), reinterpret_cast(&data.sin6.sin6_addr.s6_addr), sizeof(data.sin6.sin6_addr.s6_addr)); break; } case QType::CNAME: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.getTarget().toString()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getTarget().toString()); break; } case QType::TXT: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.d_text); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->d_text); break; } case QType::NS: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.getNS().toString()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getNS().toString()); break; } case QType::PTR: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.getContent().toString()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getContent().toString()); break; } case QType::MX: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.d_mxname.toString()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->d_mxname.toString()); break; } case QType::SPF: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.getText()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getText()); break; } case QType::SRV: { - const auto& content = dynamic_cast(*(record.d_content)); - add(content.d_target.toString()); + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->d_target.toString()); break; } default: diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index 1177f66ebfaf..2f2cbfabec4e 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -48,7 +48,7 @@ struct ZoneData // Potentially the two fields below could be merged into a single map. ATM it is not clear to me // if that would make the code easier to read. std::map, vector> d_all; - std::map, vector>> d_sigs; + std::map, vector>> d_sigs; // Maybe use a SuffixMatchTree? std::set d_delegations; @@ -105,7 +105,7 @@ void ZoneData::parseDRForCache(DNSRecord& dr) found->second.push_back(rr); } else { - vector> sigsrr; + vector> sigsrr; sigsrr.push_back(rr); d_sigs.insert({sigkey, sigsrr}); } @@ -401,7 +401,7 @@ void ZoneData::ZoneToCache(const RecZoneToCache::Config& config) case QType::RRSIG: break; default: { - vector> sigsrr; + vector> sigsrr; auto it = d_sigs.find(key); if (it != d_sigs.end()) { sigsrr = it->second; diff --git a/pdns/recursordist/recursor_cache.cc b/pdns/recursordist/recursor_cache.cc index 2bf5d556e999..e5d96c3d5de3 100644 --- a/pdns/recursordist/recursor_cache.cc +++ b/pdns/recursordist/recursor_cache.cc @@ -139,7 +139,7 @@ static void updateDNSSECValidationStateFromCache(boost::optional& state, } } -time_t MemRecursorCache::handleHit(MapCombo::LockedContent& content, MemRecursorCache::OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::vector>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) +time_t MemRecursorCache::handleHit(MapCombo::LockedContent& content, MemRecursorCache::OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::vector>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) { // MUTEX SHOULD BE ACQUIRED (as indicated by the reference to the content which is protected by a lock) time_t ttd = entry->d_ttd; @@ -157,7 +157,7 @@ time_t MemRecursorCache::handleHit(MapCombo::LockedContent& content, MemRecursor dr.d_name = qname; dr.d_type = entry->d_qtype; dr.d_class = QClass::IN; - dr.d_content = k; + dr.setContent(k); // coverity[store_truncates_time_t] dr.d_ttl = static_cast(entry->d_ttd); dr.d_place = DNSResourceRecord::ANSWER; @@ -345,7 +345,7 @@ time_t MemRecursorCache::fakeTTD(MemRecursorCache::OrderedTagIterator_t& entry, return ttl; } // returns -1 for no hits -time_t MemRecursorCache::get(time_t now, const DNSName& qname, const QType qt, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag, vector>* signatures, std::vector>* authorityRecs, bool* variable, vState* state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) +time_t MemRecursorCache::get(time_t now, const DNSName& qname, const QType qt, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag, vector>* signatures, std::vector>* authorityRecs, bool* variable, vState* state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) { bool requireAuth = flags & RequireAuth; bool refresh = flags & Refresh; @@ -530,7 +530,7 @@ bool MemRecursorCache::CacheEntry::shouldReplace(time_t now, bool auth, vState s return true; } -void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, const vector& content, const vector>& signatures, const std::vector>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask, const OptTag& routingTag, vState state, boost::optional from, bool refresh) +void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, const vector& content, const vector>& signatures, const std::vector>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask, const OptTag& routingTag, vState state, boost::optional from, bool refresh) { auto& mc = getMap(qname); auto map = mc.lock(); @@ -607,7 +607,7 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, prior to calling this function, so the TTL actually holds a TTD. */ ce.d_ttd = min(maxTTD, static_cast(i.d_ttl)); // XXX this does weird things if TTLs differ in the set ce.d_orig_ttl = ce.d_ttd - now; - ce.d_records.push_back(i.d_content); + ce.d_records.push_back(i.getContent()); } if (!isNew) { diff --git a/pdns/recursordist/recursor_cache.hh b/pdns/recursordist/recursor_cache.hh index 91102d99ae2e..ce37145f003e 100644 --- a/pdns/recursordist/recursor_cache.hh +++ b/pdns/recursordist/recursor_cache.hh @@ -67,9 +67,9 @@ public: static constexpr Flags Refresh = 1 << 1; static constexpr Flags ServeStale = 1 << 2; - time_t get(time_t, const DNSName& qname, const QType qt, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector>* signatures = nullptr, std::vector>* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr); + time_t get(time_t, const DNSName& qname, const QType qt, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector>* signatures = nullptr, std::vector>* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr); - void replace(time_t, const DNSName& qname, const QType qt, const vector& content, const vector>& signatures, const std::vector>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional from = boost::none, bool refresh = false); + void replace(time_t, const DNSName& qname, const QType qt, const vector& content, const vector>& signatures, const std::vector>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional from = boost::none, bool refresh = false); void doPrune(size_t keep); uint64_t doDump(int fd, size_t maxCacheEntries); @@ -88,7 +88,7 @@ private: { } - typedef vector> records_t; + typedef vector> records_t; bool isStale(time_t now) const { @@ -110,7 +110,7 @@ private: bool shouldReplace(time_t now, bool auth, vState state, bool refresh); records_t d_records; - std::vector> d_signatures; + std::vector> d_signatures; std::vector> d_authorityRecs; DNSName d_qname; DNSName d_authZone; @@ -278,7 +278,7 @@ private: Entries getEntries(MapCombo::LockedContent& content, const DNSName& qname, const QType qt, const OptTag& rtag); cache_t::const_iterator getEntryUsingECSIndex(MapCombo::LockedContent& content, time_t now, const DNSName& qname, QType qtype, bool requireAuth, const ComboAddress& who, bool serveStale); - time_t handleHit(MapCombo::LockedContent& content, OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::vector>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* authZone, ComboAddress* fromAuthIP); + time_t handleHit(MapCombo::LockedContent& content, OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::vector>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* authZone, ComboAddress* fromAuthIP); void updateStaleEntry(time_t now, OrderedTagIterator_t& entry); void handleServeStaleBookkeeping(time_t, bool, OrderedTagIterator_t&); diff --git a/pdns/recursordist/reczones-helpers.cc b/pdns/recursordist/reczones-helpers.cc index 1d69a402bf2e..41a36dc7f021 100644 --- a/pdns/recursordist/reczones-helpers.cc +++ b/pdns/recursordist/reczones-helpers.cc @@ -34,14 +34,14 @@ static SyncRes::AuthDomain makeSOAAndNSNodes(DNSRecord& dr, T content) dr.d_place = DNSResourceRecord::ANSWER; dr.d_ttl = 86400; dr.d_type = QType::SOA; - dr.d_content = DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800"); + dr.setContent(DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800")); SyncRes::AuthDomain ad; ad.d_rdForward = false; ad.d_records.insert(dr); dr.d_type = QType::NS; - dr.d_content = std::make_shared(content); + dr.setContent(std::make_shared(content)); ad.d_records.insert(dr); return ad; @@ -87,7 +87,7 @@ static void makeNameToIPZone(SyncRes::domainmap_t& newMap, auto recType = address.isIPv6() ? QType::AAAA : QType::A; dr.d_type = recType; dr.d_ttl = 86400; - dr.d_content = DNSRecordContent::mastermake(recType, QClass::IN, address.toStringNoInterface()); + dr.setContent(DNSRecordContent::mastermake(recType, QClass::IN, address.toStringNoInterface())); entry->second.d_records.insert(dr); } @@ -105,7 +105,7 @@ static void makeIPToNamesZone(SyncRes::domainmap_t& newMap, // Add a PTR entry for the primary name for reverse lookups. dr.d_type = QType::PTR; - dr.d_content = DNSRecordContent::mastermake(QType::PTR, 1, DNSName(canonicalHostname).toString()); + dr.setContent(DNSRecordContent::mastermake(QType::PTR, 1, DNSName(canonicalHostname).toString())); ad.d_records.insert(dr); addToDomainMap(newMap, ad, dr.d_name, log, false, true); diff --git a/pdns/recursordist/reczones.cc b/pdns/recursordist/reczones.cc index 4af95fee50ed..62aaf25d62d4 100644 --- a/pdns/recursordist/reczones.cc +++ b/pdns/recursordist/reczones.cc @@ -66,8 +66,8 @@ bool primeHints(time_t ignored) templ[sizeof(templ) - 1] = '\0'; *templ = c; aaaarr.d_name = arr.d_name = DNSName(templ); - nsrr.d_content = std::make_shared(DNSName(templ)); - arr.d_content = std::make_shared(ComboAddress(rootIps4[c - 'a'])); + nsrr.setContent(std::make_shared(DNSName(templ))); + arr.setContent(std::make_shared(ComboAddress(rootIps4[c - 'a']))); vector aset; aset.push_back(arr); /* @@ -81,13 +81,13 @@ bool primeHints(time_t ignored) * all root-server.net names will be marked auth and will expire at the same time. A re-prime is then triggered, * as before, when the records were inserted with the auth bit set and the TTD comes. */ - g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); // auth, nuke it all + g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); // auth, nuke it all if (rootIps6[c - 'a'] != NULL) { - aaaarr.d_content = std::make_shared(ComboAddress(rootIps6[c - 'a'])); + aaaarr.setContent(std::make_shared(ComboAddress(rootIps6[c - 'a']))); vector aaaaset; aaaaset.push_back(aaaarr); - g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); + g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); } nsset.push_back(nsrr); @@ -108,13 +108,13 @@ bool primeHints(time_t ignored) seenA.insert(rr.qname); vector aset; aset.push_back(DNSRecord(rr)); - g_recCache->replace(now, rr.qname, QType(QType::A), aset, vector>(), vector>(), true, g_rootdnsname, boost::none, boost::none, validationState, from); // auth, etc see above + g_recCache->replace(now, rr.qname, QType(QType::A), aset, vector>(), vector>(), true, g_rootdnsname, boost::none, boost::none, validationState, from); // auth, etc see above } else if (rr.qtype.getCode() == QType::AAAA) { seenAAAA.insert(rr.qname); vector aaaaset; aaaaset.push_back(DNSRecord(rr)); - g_recCache->replace(now, rr.qname, QType(QType::AAAA), aaaaset, vector>(), vector>(), true, g_rootdnsname, boost::none, boost::none, validationState, from); + g_recCache->replace(now, rr.qname, QType(QType::AAAA), aaaaset, vector>(), vector>(), true, g_rootdnsname, boost::none, boost::none, validationState, from); } else if (rr.qtype.getCode() == QType::NS) { seenNS.insert(DNSName(rr.content)); @@ -155,7 +155,7 @@ bool primeHints(time_t ignored) } g_recCache->doWipeCache(g_rootdnsname, false, QType::NS); - g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); // and stuff in the cache + g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), vector>(), false, g_rootdnsname, boost::none, boost::none, validationState, from); // and stuff in the cache return true; } diff --git a/pdns/recursordist/rpzloader.cc b/pdns/recursordist/rpzloader.cc index 16008f3b4621..f81ef2fbce4e 100644 --- a/pdns/recursordist/rpzloader.cc +++ b/pdns/recursordist/rpzloader.cc @@ -124,7 +124,7 @@ static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptrgetZoneRepresentation()<<" for "< loadRPZFromServer(Logr::log_t plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout) +static shared_ptr loadRPZFromServer(Logr::log_t plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout) { auto logger = plogger->withValues("primary", Logging::Loggable(primary)); @@ -216,7 +216,7 @@ static shared_ptr loadRPZFromServer(Logr::log_t plogger, const time_t last = 0; time_t axfrStart = time(nullptr); time_t axfrNow = time(nullptr); - shared_ptr sr; + shared_ptr sr; while (axfr.getChunk(nop, &chunk, (axfrStart + axfrTimeout - axfrNow))) { for (auto& dr : chunk) { if (dr.d_type == QType::NS || dr.d_type == QType::TSIG) { @@ -286,9 +286,9 @@ static void setRPZZoneNewState(const std::string& zone, uint32_t serial, uint64_ } // this function is silent - you do the logging -std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL) +std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL) { - shared_ptr sr = nullptr; + shared_ptr sr = nullptr; ZoneParserTNG zpt(fname); zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps")); zpt.setMaxIncludes(::arg().asNum("max-include-depth")); @@ -381,7 +381,7 @@ static bool dumpZoneToDisk(Logr::log_t logger, const DNSName& zoneName, const st return true; } -void RPZIXFRTracker(const std::vector& primaries, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t xfrTimeout, const uint32_t refreshFromConf, std::shared_ptr sr, const std::string& dumpZoneFileName, uint64_t configGeneration) +void RPZIXFRTracker(const std::vector& primaries, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t xfrTimeout, const uint32_t refreshFromConf, std::shared_ptr sr, const std::string& dumpZoneFileName, uint64_t configGeneration) { setThreadName("rec/rpzixfr"); bool isPreloaded = sr != nullptr; @@ -450,7 +450,7 @@ void RPZIXFRTracker(const std::vector& primaries, const boost::opt for (;;) { DNSRecord dr; - dr.d_content = sr; + dr.setContent(sr); if (skipRefreshDelay) { skipRefreshDelay = false; @@ -516,7 +516,7 @@ void RPZIXFRTracker(const std::vector& primaries, const boost::opt /* we need to make a _full copy_ of the zone we are going to work on */ std::shared_ptr newZone = std::make_shared(*oldZone); /* initialize the current serial to the last one */ - std::shared_ptr currentSR = sr; + std::shared_ptr currentSR = sr; int totremove = 0, totadd = 0; bool fullUpdate = false; diff --git a/pdns/recursordist/rpzloader.hh b/pdns/recursordist/rpzloader.hh index fcb379cb4b20..8f37a0b4c0f7 100644 --- a/pdns/recursordist/rpzloader.hh +++ b/pdns/recursordist/rpzloader.hh @@ -26,8 +26,8 @@ extern bool g_logRPZChanges; -std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL); -void RPZIXFRTracker(const std::vector& primaries, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t xfrTimeout, const uint32_t reloadFromConf, shared_ptr sr, const std::string& dumpZoneFileName, uint64_t configGeneration); +std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL); +void RPZIXFRTracker(const std::vector& primaries, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t xfrTimeout, const uint32_t reloadFromConf, shared_ptr sr, const std::string& dumpZoneFileName, uint64_t configGeneration); struct rpzStats { diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 0c24565a3441..122ad98aa54f 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -865,7 +865,7 @@ bool SyncRes::doSpecialNamesResolve(const DNSName& qname, const QType qtype, con dr.d_ttl = 86400; for (const auto& ans : answers) { dr.d_type = ans.first; - dr.d_content = DNSRecordContent::mastermake(ans.first, qclass, ans.second); + dr.setContent(DNSRecordContent::mastermake(ans.first, qclass, ans.second)); ret.push_back(dr); } } @@ -2402,7 +2402,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector< } vector cset; - vector> signatures; + vector> signatures; vector> authorityRecs; bool wasAuth; uint32_t capTTL = std::numeric_limits::max(); @@ -2480,7 +2480,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector< } } - LOG(prefix << qname << ": Found cache " << foundQT.toString() << " hit for '" << foundName << "|" << foundQT.toString() << "' to '" << record.d_content->getZoneRepresentation() << "', validation state is " << context.state << endl); + LOG(prefix << qname << ": Found cache " << foundQT.toString() << " hit for '" << foundName << "|" << foundQT.toString() << "' to '" << record.getContent()->getZoneRepresentation() << "', validation state is " << context.state << endl); DNSRecord dr = record; dr.d_ttl -= d_now.tv_sec; @@ -2494,7 +2494,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector< sigdr.d_type = QType::RRSIG; sigdr.d_name = foundName; sigdr.d_ttl = ttl; - sigdr.d_content = signature; + sigdr.setContent(signature); sigdr.d_place = DNSResourceRecord::ANSWER; sigdr.d_class = QClass::IN; ret.push_back(sigdr); @@ -2523,7 +2523,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector< dr.d_type = QType::CNAME; dr.d_name = targetPrefix + foundName; newTarget = targetPrefix + dnameSuffix; - dr.d_content = std::make_shared(CNAMERecordContent(newTarget)); + dr.setContent(std::make_shared(CNAMERecordContent(newTarget))); ret.push_back(dr); } catch (const std::exception& e) { @@ -2599,7 +2599,7 @@ namespace struct CacheEntry { vector records; - vector> signatures; + vector> signatures; uint32_t signaturesTTL{std::numeric_limits::max()}; }; struct CacheKey @@ -2612,7 +2612,7 @@ struct CacheKey return std::tie(type, place, name) < std::tie(rhs.type, rhs.place, rhs.name); } }; -typedef map tcache_t; +using tcache_t = map; } static void reapRecordsFromNegCacheEntryForValidation(tcache_t& tcache, const vector& records) @@ -2642,7 +2642,7 @@ static void reapRecordsForValidation(std::map& entries, const } } -static void reapSignaturesForValidation(std::map& entries, const vector>& signatures) +static void reapSignaturesForValidation(std::map& entries, const vector>& signatures) { for (const auto& sig : signatures) { entries[sig->d_type].signatures.push_back(sig); @@ -2823,7 +2823,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w vector cset; bool found = false, expired = false; - vector> signatures; + vector> signatures; vector> authorityRecs; uint32_t ttl = 0; uint32_t capTTL = std::numeric_limits::max(); @@ -2891,7 +2891,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w for (auto j = cset.cbegin(); j != cset.cend(); ++j) { - LOG(j->d_content->getZoneRepresentation()); + LOG(j->getContent()->getZoneRepresentation()); if (j->d_class != QClass::IN) { continue; @@ -2919,7 +2919,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w dr.d_type = QType::RRSIG; dr.d_name = sqname; dr.d_ttl = ttl; - dr.d_content = signature; + dr.setContent(signature); dr.d_place = DNSResourceRecord::ANSWER; dr.d_class = QClass::IN; ret.push_back(dr); @@ -3033,7 +3033,7 @@ vector SyncRes::shuffleForwardSpeed(const DNSName& qname, const ve return nameservers; } -static uint32_t getRRSIGTTL(const time_t now, const std::shared_ptr& rrsig) +static uint32_t getRRSIGTTL(const time_t now, const std::shared_ptr& rrsig) { uint32_t res = 0; if (now < rrsig->d_sigexpire) { @@ -3109,7 +3109,7 @@ static cspmap_t harvestCSPFromNE(const NegCache::NegCacheEntry& ne) } } for (const auto& rec : ne.DNSSECRecords.records) { - cspmap[{rec.d_name, rec.d_type}].records.insert(rec.d_content); + cspmap[{rec.d_name, rec.d_type}].records.insert(rec.getContent()); } return cspmap; } @@ -3413,7 +3413,7 @@ bool SyncRes::validationEnabled() const return g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate; } -uint32_t SyncRes::computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::vector>& authorityRecs) const +uint32_t SyncRes::computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::vector>& authorityRecs) const { uint32_t lowestTTD = std::numeric_limits::max(); for (const auto& record : records) { @@ -3738,7 +3738,7 @@ vState SyncRes::getValidationStatus(const DNSName& name, bool wouldBeValid, bool return result; } -vState SyncRes::validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector>& signatures, unsigned int depth, const string& prefix) +vState SyncRes::validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector>& signatures, unsigned int depth, const string& prefix) { dsmap_t ds; if (signatures.empty()) { @@ -3849,7 +3849,7 @@ vState SyncRes::getDNSKeys(const DNSName& signer, skeyset_t& keys, bool& servFai return vState::BogusUnableToGetDNSKEYs; } -vState SyncRes::validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector& records, const std::vector>& signatures) +vState SyncRes::validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector& records, const std::vector>& signatures) { skeyset_t keys; if (signatures.empty()) { @@ -3945,7 +3945,7 @@ vState SyncRes::validateRecordsWithSigs(unsigned int depth, const string& prefix sortedRecords_t recordcontents; for (const auto& record : records) { - recordcontents.insert(record.d_content); + recordcontents.insert(record.getContent()); } LOG(prefix << name << ": Going to validate " << recordcontents.size() << " record contents with " << signatures.size() << " sigs and " << keys.size() << " keys for " << name << "|" << type.toString() << endl); @@ -4086,7 +4086,7 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN } if (!rec->d_name.isPartOf(auth)) { - LOG(prefix << qname << ": Removing record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section received from " << auth << endl); + LOG(prefix << qname << ": Removing record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4096,20 +4096,20 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN /* for now we allow a CNAME for the exact qname in ANSWER with AA=0, because Amazon DNS servers are sending such responses */ if (!(rec->d_type == QType::CNAME && qname == rec->d_name)) { - LOG(prefix << qname << ": Removing record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the answer section without the AA bit set received from " << auth << endl); + LOG(prefix << qname << ": Removing record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the answer section without the AA bit set received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } } if (rec->d_type == QType::DNAME && (rec->d_place != DNSResourceRecord::ANSWER || !qname.isPartOf(rec->d_name))) { - LOG(prefix << qname << ": Removing invalid DNAME record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section received from " << auth << endl); + LOG(prefix << qname << ": Removing invalid DNAME record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } if (rec->d_place == DNSResourceRecord::ANSWER && (qtype != QType::ANY && rec->d_type != qtype.getCode() && s_redirectionQTypes.count(rec->d_type) == 0 && rec->d_type != QType::SOA && rec->d_type != QType::RRSIG)) { - LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the ANSWER section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the ANSWER section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4124,20 +4124,20 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN /* dealing with the records in authority */ if (rec->d_place == DNSResourceRecord::AUTHORITY && rec->d_type != QType::NS && rec->d_type != QType::DS && rec->d_type != QType::SOA && rec->d_type != QType::RRSIG && rec->d_type != QType::NSEC && rec->d_type != QType::NSEC3) { - LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } if (rec->d_place == DNSResourceRecord::AUTHORITY && rec->d_type == QType::SOA) { if (!qname.isPartOf(rec->d_name)) { - LOG(prefix << qname << ": Removing irrelevant SOA record '" << rec->d_name << "|" << rec->d_content->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant SOA record '" << rec->d_name << "|" << rec->getContent()->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } if (!(lwr.d_aabit || wasForwardRecurse)) { - LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the AUTHORITY section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4158,7 +4158,7 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN * because they are somewhat easy to insert into a large, fragmented UDP response * for an off-path attacker by injecting spoofed UDP fragments. So do not add these to allowedAdditionals. */ - LOG(prefix << qname << ": Removing NS record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section of a " << (isNXDomain ? "NXD" : "NXQTYPE") << " response received from " << auth << endl); + LOG(prefix << qname << ": Removing NS record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section of a " << (isNXDomain ? "NXD" : "NXQTYPE") << " response received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4168,7 +4168,7 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN * We don't want to pick up root NS records in AUTHORITY and their associated ADDITIONAL sections of random queries. * So don't add them to allowedAdditionals. */ - LOG(prefix << qname << ": Removing NS record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section of a response received from " << auth << endl); + LOG(prefix << qname << ": Removing NS record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the " << (int)rec->d_place << " section of a response received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4179,13 +4179,13 @@ void SyncRes::sanitizeRecords(const std::string& prefix, LWResult& lwr, const DN /* dealing with the records in additional */ if (rec->d_place == DNSResourceRecord::ADDITIONAL && rec->d_type != QType::A && rec->d_type != QType::AAAA && rec->d_type != QType::RRSIG) { - LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the ADDITIONAL section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the ADDITIONAL section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } if (rec->d_place == DNSResourceRecord::ADDITIONAL && allowedAdditionals.count(rec->d_name) == 0) { - LOG(prefix << qname << ": Removing irrelevant additional record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->d_content->getZoneRepresentation() << "' in the ADDITIONAL section received from " << auth << endl); + LOG(prefix << qname << ": Removing irrelevant additional record '" << rec->d_name << "|" << DNSRecordContent::NumberToType(rec->d_type) << "|" << rec->getContent()->getZoneRepresentation() << "' in the ADDITIONAL section received from " << auth << endl); rec = lwr.d_records.erase(rec); continue; } @@ -4334,7 +4334,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& continue; } - LOG(prefix << qname << ": Accept answer '" << rec.d_name << "|" << DNSRecordContent::NumberToType(rec.d_type) << "|" << rec.d_content->getZoneRepresentation() << "' from '" << auth << "' nameservers? ttl=" << rec.d_ttl << ", place=" << (int)rec.d_place << " "); + LOG(prefix << qname << ": Accept answer '" << rec.d_name << "|" << DNSRecordContent::NumberToType(rec.d_type) << "|" << rec.getContent()->getZoneRepresentation() << "' from '" << auth << "' nameservers? ttl=" << rec.d_ttl << ", place=" << (int)rec.d_place << " "); // We called sanitizeRecords before, so all ANY, non-IN and non-aa/non-forwardrecurse answer records are already removed @@ -4789,7 +4789,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co } // for ANY answers we *must* have an authoritative answer, unless we are forwarding recursively else if (rec.d_place == DNSResourceRecord::ANSWER && rec.d_name == qname && (rec.d_type == qtype.getCode() || ((lwr.d_aabit || sendRDQuery) && qtype == QType::ANY))) { - LOG(prefix << qname << ": Answer is in: resolved to '" << rec.d_content->getZoneRepresentation() << "|" << DNSRecordContent::NumberToType(rec.d_type) << "'" << endl); + LOG(prefix << qname << ": Answer is in: resolved to '" << rec.getContent()->getZoneRepresentation() << "|" << DNSRecordContent::NumberToType(rec.d_type) << "'" << endl); done = true; rcode = RCode::NoError; @@ -4852,7 +4852,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co else if (rec.d_place == DNSResourceRecord::AUTHORITY && rec.d_type == QType::NS && qname.isPartOf(rec.d_name)) { if (moreSpecificThan(rec.d_name, auth)) { newauth = rec.d_name; - LOG(prefix << qname << ": Got NS record '" << rec.d_name << "' -> '" << rec.d_content->getZoneRepresentation() << "'" << endl); + LOG(prefix << qname << ": Got NS record '" << rec.d_name << "' -> '" << rec.getContent()->getZoneRepresentation() << "'" << endl); /* check if we have a referral from the parent zone to a child zone for a DS query, which is not right */ if (qtype == QType::DS && (newauth.isPartOf(qname) || qname == newauth)) { @@ -4867,14 +4867,14 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co } } else { - LOG(prefix << qname << ": Got upwards/level NS record '" << rec.d_name << "' -> '" << rec.d_content->getZoneRepresentation() << "', had '" << auth << "'" << endl); + LOG(prefix << qname << ": Got upwards/level NS record '" << rec.d_name << "' -> '" << rec.getContent()->getZoneRepresentation() << "', had '" << auth << "'" << endl); if (auto content = getRR(rec)) { nsset.insert(content->getNS()); } } } else if (rec.d_place == DNSResourceRecord::AUTHORITY && rec.d_type == QType::DS && qname.isPartOf(rec.d_name)) { - LOG(prefix << qname << ": Got DS record '" << rec.d_name << "' -> '" << rec.d_content->getZoneRepresentation() << "'" << endl); + LOG(prefix << qname << ": Got DS record '" << rec.d_name << "' -> '" << rec.getContent()->getZoneRepresentation() << "'" << endl); } else if (realreferral && rec.d_place == DNSResourceRecord::AUTHORITY && (rec.d_type == QType::NSEC || rec.d_type == QType::NSEC3) && newauth.isPartOf(auth)) { /* we might have received a denial of the DS, let's check */ @@ -4971,7 +4971,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co cnamerec.d_name = qname; cnamerec.d_type = QType::CNAME; cnamerec.d_ttl = dnameTTL; - cnamerec.d_content = std::make_shared(CNAMERecordContent(newtarget)); + cnamerec.setContent(std::make_shared(CNAMERecordContent(newtarget))); ret.push_back(std::move(cnamerec)); } diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index 1b99c277f02c..ca57f99b534d 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -652,10 +652,10 @@ private: boost::optional getEDNSSubnetMask(const DNSName& dn, const ComboAddress& rem); bool validationEnabled() const; - uint32_t computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::vector>& authorityRecs) const; + uint32_t computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::vector>& authorityRecs) const; void updateValidationState(const DNSName& qname, vState& state, const vState stateUpdate, const string& prefix); - vState validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector& records, const std::vector>& signatures); - vState validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector>& signatures, unsigned int depth, const string& prefix); + vState validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector& records, const std::vector>& signatures); + vState validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector>& signatures, unsigned int depth, const string& prefix); vState getDNSKeys(const DNSName& signer, skeyset_t& keys, bool& servFailOccurred, unsigned int depth, const string& prefix); dState getDenialValidationState(const NegCache::NegCacheEntry& ne, const dState expectedState, bool referralToUnsigned, const string& prefix); void updateDenialValidationState(const DNSName& qname, vState& neValidationState, const DNSName& neName, vState& state, const dState denialState, const dState expectedState, bool isDS, unsigned int depth, const string& prefix); diff --git a/pdns/recursordist/test-aggressive_nsec_cc.cc b/pdns/recursordist/test-aggressive_nsec_cc.cc index 3892d246d9fa..73d75ec6cd6f 100644 --- a/pdns/recursordist/test-aggressive_nsec_cc.cc +++ b/pdns/recursordist/test-aggressive_nsec_cc.cc @@ -1087,18 +1087,18 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_wiping) rec.d_name = DNSName("www.powerdns.com"); rec.d_type = QType::NSEC; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC")); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); rec.d_name = DNSName("z.powerdns.com"); - rec.d_content = getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC")); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); rec.d_name = DNSName("www.powerdns.org"); rec.d_type = QType::NSEC3; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC3, "1 0 500 ab HASG==== A RRSIG NSEC3"); + rec.setContent(getRecordContent(QType::NSEC3, "1 0 500 ab HASG==== A RRSIG NSEC3")); rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.org"), rec.d_name, rec, {rrsig}, true); @@ -1136,12 +1136,12 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_pruning) rec.d_name = DNSName("www.powerdns.com"); rec.d_type = QType::NSEC; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC")); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); rec.d_name = DNSName("z.powerdns.com"); - rec.d_content = getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC")); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); BOOST_CHECK_EQUAL(cache->getEntriesCount(), 2U); @@ -1153,7 +1153,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_pruning) rec.d_name = DNSName("www.powerdns.org"); rec.d_type = QType::NSEC3; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC3, "1 0 500 ab HASG==== A RRSIG NSEC3"); + rec.setContent(getRecordContent(QType::NSEC3, "1 0 500 ab HASG==== A RRSIG NSEC3")); rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.org"), rec.d_name, rec, {rrsig}, true); @@ -1197,18 +1197,18 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_dump) rec.d_name = DNSName("www.powerdns.com"); rec.d_type = QType::NSEC; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "z.powerdns.com. A RRSIG NSEC")); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); rec.d_name = DNSName("z.powerdns.com"); - rec.d_content = getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC"); + rec.setContent(getRecordContent(QType::NSEC, "zz.powerdns.com. AAAA RRSIG NSEC")); cache->insertNSEC(DNSName("powerdns.com"), rec.d_name, rec, {rrsig}, false); rec.d_name = DNSName("www.powerdns.org"); rec.d_type = QType::NSEC3; rec.d_ttl = now.tv_sec + 10; - rec.d_content = getRecordContent(QType::NSEC3, "1 0 50 ab HASG==== A RRSIG NSEC3"); + rec.setContent(getRecordContent(QType::NSEC3, "1 0 50 ab HASG==== A RRSIG NSEC3")); rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(DNSName("powerdns.org"), rec.d_name, rec, {rrsig}, true); @@ -1258,7 +1258,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) drSOA.d_name = zone; drSOA.d_type = QType::SOA; drSOA.d_class = QClass::IN; - drSOA.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + drSOA.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); drSOA.d_ttl = static_cast(ttd); // XXX truncation drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); @@ -1289,7 +1289,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1318,7 +1318,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1348,7 +1348,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 dummy. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1378,7 +1378,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) drSOA.d_name = zone; drSOA.d_type = QType::SOA; drSOA.d_class = QClass::IN; - drSOA.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + drSOA.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); drSOA.d_ttl = static_cast(ttd); // XXX truncation drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); @@ -1401,7 +1401,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 sub.powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, false); @@ -1434,7 +1434,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, false); @@ -1466,7 +1466,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, false); @@ -1504,7 +1504,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, false); @@ -1523,7 +1523,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, false); @@ -1561,7 +1561,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) drSOA.d_name = zone; drSOA.d_type = QType::SOA; drSOA.d_class = QClass::IN; - drSOA.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + drSOA.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); drSOA.d_ttl = static_cast(ttd); // XXX truncation drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); @@ -1593,7 +1593,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 sub.powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1632,7 +1632,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1670,7 +1670,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1717,7 +1717,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1745,7 +1745,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1773,7 +1773,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1822,7 +1822,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1850,7 +1850,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); @@ -1878,7 +1878,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) nrc.set(type); } - rec.d_content = std::make_shared(nrc); + rec.setContent(std::make_shared(nrc)); auto rrsig = std::make_shared("NSEC3 5 3 10 20370101000000 20370101000000 24567 powerdns.com. data"); cache->insertNSEC(zone, rec.d_name, rec, {rrsig}, true); diff --git a/pdns/recursordist/test-filterpo_cc.cc b/pdns/recursordist/test-filterpo_cc.cc index 9b0ff1fe1909..ac033238197e 100644 --- a/pdns/recursordist/test-filterpo_cc.cc +++ b/pdns/recursordist/test-filterpo_cc.cc @@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_basic) /* blocked A */ DNSRecord dr; dr.d_type = QType::A; - dr.d_content = DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString()); + dr.setContent(DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString())); const auto matchingPolicy = dfe.getPostPolicy({dr}, std::unordered_map(), DNSFilterEngine::maximumPriority); BOOST_CHECK(matchingPolicy.d_type == DNSFilterEngine::PolicyType::ResponseIP); BOOST_CHECK(matchingPolicy.d_kind == DNSFilterEngine::PolicyKind::Drop); @@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_basic) /* allowed A */ DNSRecord dr; dr.d_type = QType::A; - dr.d_content = DNSRecordContent::mastermake(QType::A, QClass::IN, "192.0.2.142"); + dr.setContent(DNSRecordContent::mastermake(QType::A, QClass::IN, "192.0.2.142")); const auto matchingPolicy = dfe.getPostPolicy({dr}, std::unordered_map(), DNSFilterEngine::maximumPriority); BOOST_CHECK(matchingPolicy.d_type == DNSFilterEngine::PolicyType::None); DNSFilterEngine::Policy zonePolicy; @@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden.example.net."); } @@ -359,7 +359,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::A); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getCA().toString(), "192.0.2.1"); } @@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(1); BOOST_CHECK(record.d_type == QType::A); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getCA().toString(), "192.0.2.2"); } @@ -379,7 +379,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::MX); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->d_mxname.toString(), "garden-mail.example.net."); } @@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::A); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getCA().toString(), "192.0.2.2"); } @@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::MX); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->d_mxname.toString(), "garden-mail.example.net."); } @@ -460,14 +460,14 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data_netmask) const auto& record1 = records.at(0); BOOST_CHECK(record1.d_type == QType::A); BOOST_CHECK(record1.d_class == QClass::IN); - auto content1 = std::dynamic_pointer_cast(record1.d_content); + auto content1 = getRR(record1); BOOST_CHECK(content1 != nullptr); BOOST_CHECK_EQUAL(content1->getCA().toString(), "1.2.3.4"); const auto& record2 = records.at(1); BOOST_CHECK(record2.d_type == QType::A); BOOST_CHECK(record2.d_class == QClass::IN); - auto content2 = std::dynamic_pointer_cast(record2.d_content); + auto content2 = getRR(record2); BOOST_CHECK(content2 != nullptr); BOOST_CHECK_EQUAL(content2->getCA().toString(), "1.2.3.5"); } @@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data_netmask) const auto& record1 = records.at(0); BOOST_CHECK(record1.d_type == QType::AAAA); BOOST_CHECK(record1.d_class == QClass::IN); - auto content1 = std::dynamic_pointer_cast(record1.d_content); + auto content1 = getRR(record1); BOOST_CHECK(content1 != nullptr); BOOST_CHECK_EQUAL(content1->getCA().toString(), "::1234"); } @@ -507,7 +507,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data_netmask) const auto& record1 = records.at(0); BOOST_CHECK(record1.d_type == QType::A); BOOST_CHECK(record1.d_class == QClass::IN); - auto content1 = std::dynamic_pointer_cast(record1.d_content); + auto content1 = getRR(record1); BOOST_CHECK(content1 != nullptr); BOOST_CHECK_EQUAL(content1->getCA().toString(), "1.2.3.4"); } @@ -520,7 +520,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data_netmask) const auto& record1 = records.at(0); BOOST_CHECK(record1.d_type == QType::AAAA); BOOST_CHECK(record1.d_class == QClass::IN); - auto content1 = std::dynamic_pointer_cast(record1.d_content); + auto content1 = getRR(record1); BOOST_CHECK(content1 != nullptr); BOOST_CHECK_EQUAL(content1->getCA().toString(), "::1234"); } @@ -540,7 +540,7 @@ BOOST_AUTO_TEST_CASE(test_filter_policies_local_data_netmask) const auto& record1 = records.at(0); BOOST_CHECK(record1.d_type == QType::AAAA); BOOST_CHECK(record1.d_class == QClass::IN); - auto content1 = std::dynamic_pointer_cast(record1.d_content); + auto content1 = getRR(record1); BOOST_CHECK(content1 != nullptr); BOOST_CHECK_EQUAL(content1->getCA().toString(), "::1234"); } @@ -587,7 +587,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden1a.example.net."); } @@ -602,7 +602,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden1b.example.net."); } @@ -617,7 +617,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden1a.example.net."); } @@ -632,7 +632,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden2a.example.net."); } @@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "client1a.example.net."); } @@ -709,7 +709,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden1a.example.net."); } @@ -724,7 +724,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden1a.example.net."); } @@ -746,7 +746,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "garden2a.example.net."); } @@ -768,7 +768,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "nsname1a.example.net."); } @@ -790,7 +790,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "nsip1a.example.net."); } @@ -806,7 +806,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) /* blocked A in the response */ DNSRecord dr; dr.d_type = QType::A; - dr.d_content = DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString()); + dr.setContent(DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString())); const auto matchingPolicy = dfe.getPostPolicy({dr}, std::unordered_map(), DNSFilterEngine::maximumPriority); BOOST_CHECK(matchingPolicy.d_type == DNSFilterEngine::PolicyType::ResponseIP); BOOST_CHECK(matchingPolicy.d_kind == DNSFilterEngine::PolicyKind::Custom); @@ -815,7 +815,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) const auto& record = records.at(0); BOOST_CHECK(record.d_type == QType::CNAME); BOOST_CHECK(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_CHECK(content != nullptr); BOOST_CHECK_EQUAL(content->getTarget().toString(), "response1a.example.net."); } @@ -824,7 +824,7 @@ BOOST_AUTO_TEST_CASE(test_multiple_filter_policies_order) /* blocked A in the response, except 1 is disabled and 2's priority is too high */ DNSRecord dr; dr.d_type = QType::A; - dr.d_content = DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString()); + dr.setContent(DNSRecordContent::mastermake(QType::A, QClass::IN, responseIP.toString())); const auto matchingPolicy = dfe.getPostPolicy({dr}, {{zone1->getName(), true}}, 1); BOOST_CHECK(matchingPolicy.d_type == DNSFilterEngine::PolicyType::None); BOOST_CHECK(matchingPolicy.d_kind == DNSFilterEngine::PolicyKind::NoAction); diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index e050097ec1da..c432005ad0fe 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -15,13 +15,13 @@ static recordsAndSignatures genRecsAndSigs(const DNSName& name, const uint16_t q rec.d_type = qtype; rec.d_ttl = 600; rec.d_place = DNSResourceRecord::AUTHORITY; - rec.d_content = DNSRecordContent::mastermake(qtype, QClass::IN, content); + rec.setContent(DNSRecordContent::mastermake(qtype, QClass::IN, content)); ret.records.push_back(rec); if (sigs) { rec.d_type = QType::RRSIG; - rec.d_content = std::make_shared(QType(qtype).toString() + " 5 3 600 2037010100000000 2037010100000000 24567 dummy data"); + rec.setContent(std::make_shared(QType(qtype).toString() + " 5 3 600 2037010100000000 2037010100000000 24567 dummy data")); ret.signatures.push_back(rec); } diff --git a/pdns/recursordist/test-recursorcache_cc.cc b/pdns/recursordist/test-recursorcache_cc.cc index 5e343384f856..e456d3f11681 100644 --- a/pdns/recursordist/test-recursorcache_cc.cc +++ b/pdns/recursordist/test-recursorcache_cc.cc @@ -17,7 +17,7 @@ static void simple(time_t now) std::vector records; std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; const DNSName authZone("."); time_t ttd = now + 30; @@ -27,7 +27,7 @@ static void simple(time_t now) dr0.d_name = power; dr0.d_type = QType::AAAA; dr0.d_class = QClass::IN; - dr0.d_content = std::make_shared(dr0Content); + dr0.setContent(std::make_shared(dr0Content)); dr0.d_ttl = static_cast(ttd); // XXX truncation dr0.d_place = DNSResourceRecord::ANSWER; @@ -85,7 +85,7 @@ static void simple(time_t now) dr1.d_name = power; dr1.d_type = QType::AAAA; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); // XXX truncation dr1.d_place = DNSResourceRecord::ANSWER; @@ -94,7 +94,7 @@ static void simple(time_t now) dr2.d_name = power; dr2.d_type = QType::A; dr2.d_class = QClass::IN; - dr2.d_content = std::make_shared(dr2Content); + dr2.setContent(std::make_shared(dr2Content)); dr2.d_ttl = static_cast(ttd); // XXX truncation // the place should not matter to the cache dr2.d_place = DNSResourceRecord::AUTHORITY; @@ -233,7 +233,7 @@ static void simple(time_t now) dr3.d_name = power; dr3.d_type = QType::A; dr3.d_class = QClass::IN; - dr3.d_content = std::make_shared(dr3Content); + dr3.setContent(std::make_shared(dr3Content)); dr3.d_ttl = static_cast(ttd + 100); // XXX truncation // the place should not matter to the cache dr3.d_place = DNSResourceRecord::AUTHORITY; @@ -313,7 +313,7 @@ static void simple(time_t now) dr4.d_name = power; dr4.d_type = QType::A; dr4.d_class = QClass::IN; - dr4.d_content = std::make_shared(dr4Content); + dr4.setContent(std::make_shared(dr4Content)); dr4.d_ttl = static_cast(ttd); // XXX truncation dr4.d_place = DNSResourceRecord::AUTHORITY; @@ -391,7 +391,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheGhost) std::vector records; std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; time_t now = time(nullptr); BOOST_CHECK_EQUAL(MRC.size(), 0U); @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheGhost) ns1.d_name = ghost; ns1.d_type = QType::NS; ns1.d_class = QClass::IN; - ns1.d_content = std::make_shared(ns1Content); + ns1.setContent(std::make_shared(ns1Content)); ns1.d_ttl = static_cast(ttd); // XXX truncation ns1.d_place = DNSResourceRecord::ANSWER; records.push_back(ns1); @@ -434,7 +434,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin) std::vector records; std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; time_t now = time(nullptr); BOOST_CHECK_EQUAL(MRC.size(), 0U); @@ -447,7 +447,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin) ns1.d_name = record1; ns1.d_type = QType::NS; ns1.d_class = QClass::IN; - ns1.d_content = std::make_shared(record1); + ns1.setContent(std::make_shared(record1)); ns1.d_ttl = static_cast(ttd); // XXX truncation ns1.d_place = DNSResourceRecord::ANSWER; records.push_back(ns1); @@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) MemRecursorCache MRC(1); std::vector records; - std::vector> signatures; + std::vector> signatures; std::vector> authRecs; const DNSName authZone("."); BOOST_CHECK_EQUAL(MRC.size(), 0U); @@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) dr1.d_name = power1; dr1.d_type = QType::AAAA; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); // XXX truncation dr1.d_place = DNSResourceRecord::ANSWER; @@ -505,7 +505,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) dr2.d_name = power2; dr2.d_type = QType::AAAA; dr2.d_class = QClass::IN; - dr2.d_content = std::make_shared(dr2Content); + dr2.setContent(std::make_shared(dr2Content)); dr2.d_ttl = static_cast(ttd); // XXX truncation dr2.d_place = DNSResourceRecord::ANSWER; @@ -572,7 +572,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) MemRecursorCache MRC(1); std::vector records; - std::vector> signatures; + std::vector> signatures; std::vector> authRecs; const DNSName authZone("."); BOOST_CHECK_EQUAL(MRC.size(), 0U); @@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) dr1.d_name = power1; dr1.d_type = QType::AAAA; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); dr1.d_place = DNSResourceRecord::ANSWER; @@ -599,7 +599,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) dr2.d_name = power2; dr2.d_type = QType::AAAA; dr2.d_class = QClass::IN; - dr2.d_content = std::make_shared(dr2Content); + dr2.setContent(std::make_shared(dr2Content)); dr2.d_ttl = static_cast(ttd); dr2.d_place = DNSResourceRecord::ANSWER; @@ -703,7 +703,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) r1.d_name = power1; r1.d_type = QType::A; r1.d_class = QClass::IN; - r1.d_content = std::make_shared(r1Content); + r1.setContent(std::make_shared(r1Content)); r1.d_ttl = static_cast(ttd); r1.d_place = DNSResourceRecord::ANSWER; records.push_back(r1); @@ -753,7 +753,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex) const DNSName authZone("."); std::vector records; std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; time_t now = time(nullptr); std::vector retrieved; ComboAddress who("192.0.2.1"); @@ -765,7 +765,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex) dr1.d_name = power; dr1.d_type = QType::A; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); dr1.d_place = DNSResourceRecord::ANSWER; @@ -774,7 +774,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex) dr2.d_name = power; dr2.d_type = QType::A; dr2.d_class = QClass::IN; - dr2.d_content = std::make_shared(dr2Content); + dr2.setContent(std::make_shared(dr2Content)); dr2.d_ttl = static_cast(now + 5); dr2.d_place = DNSResourceRecord::ANSWER; @@ -912,7 +912,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe) const DNSName authZone("."); std::vector records; std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; time_t now = time(nullptr); std::vector retrieved; ComboAddress who("192.0.2.1"); @@ -924,7 +924,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe) dr1.d_name = power; dr1.d_type = QType::A; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); dr1.d_place = DNSResourceRecord::ANSWER; @@ -1000,7 +1000,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) const DNSName authZone("."); std::vector> authRecords; - std::vector> signatures; + std::vector> signatures; time_t now = time(nullptr); time_t ttd = now + 30; @@ -1010,7 +1010,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) dr0.d_name = power; dr0.d_type = QType::A; dr0.d_class = QClass::IN; - dr0.d_content = std::make_shared(dr0Content); + dr0.setContent(std::make_shared(dr0Content)); dr0.d_ttl = static_cast(ttd); dr0.d_place = DNSResourceRecord::ANSWER; std::vector rset0; @@ -1021,7 +1021,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) dr0tagged.d_name = power; dr0tagged.d_type = QType::A; dr0tagged.d_class = QClass::IN; - dr0tagged.d_content = std::make_shared(dr0taggedContent); + dr0tagged.setContent(std::make_shared(dr0taggedContent)); dr0tagged.d_ttl = static_cast(ttd); dr0tagged.d_place = DNSResourceRecord::ANSWER; std::vector rset0tagged; @@ -1136,7 +1136,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) dr1.d_name = power; dr1.d_type = QType::A; dr1.d_class = QClass::IN; - dr1.d_content = std::make_shared(dr1Content); + dr1.setContent(std::make_shared(dr1Content)); dr1.d_ttl = static_cast(ttd); dr1.d_place = DNSResourceRecord::ANSWER; std::vector rset1; @@ -1147,7 +1147,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) dr2.d_name = power; dr2.d_type = QType::A; dr2.d_class = QClass::IN; - dr2.d_content = std::make_shared(dr2Content); + dr2.setContent(std::make_shared(dr2Content)); dr2.d_ttl = static_cast(ttd); dr2.d_place = DNSResourceRecord::ANSWER; std::vector rset2; @@ -1158,7 +1158,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) dr3.d_name = power; dr3.d_type = QType::A; dr3.d_class = QClass::IN; - dr3.d_content = std::make_shared(dr3Content); + dr3.setContent(std::make_shared(dr3Content)); dr3.d_ttl = static_cast(ttd); dr3.d_place = DNSResourceRecord::ANSWER; std::vector rset3; diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index a9058e15ae40..52b773c7658d 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -96,22 +96,22 @@ bool primeHints(time_t now) templ[sizeof(templ) - 1] = '\0'; *templ = c; aaaarr.d_name = arr.d_name = DNSName(templ); - nsrr.d_content = std::make_shared(DNSName(templ)); - arr.d_content = std::make_shared(ComboAddress(rootIps4[c - 'a'])); + nsrr.setContent(std::make_shared(DNSName(templ))); + arr.setContent(std::make_shared(ComboAddress(rootIps4[c - 'a']))); vector aset; aset.push_back(arr); - g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), vector>(), false, g_rootdnsname); + g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), vector>(), false, g_rootdnsname); if (rootIps6[c - 'a'] != NULL) { - aaaarr.d_content = std::make_shared(ComboAddress(rootIps6[c - 'a'])); + aaaarr.setContent(std::make_shared(ComboAddress(rootIps6[c - 'a']))); vector aaaaset; aaaaset.push_back(aaaarr); - g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), vector>(), false, g_rootdnsname); + g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), vector>(), false, g_rootdnsname); } nsset.push_back(nsrr); } - g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), vector>(), false, g_rootdnsname); // and stuff in the cache + g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), vector>(), false, g_rootdnsname); // and stuff in the cache return true; } @@ -332,7 +332,7 @@ bool addRRSIG(const testkeysset_t& keys, std::vector& records, const sortedRecords_t recordcontents; for (const auto& record : records) { if (record.d_name == name && record.d_type == type) { - recordcontents.insert(record.d_content); + recordcontents.insert(record.getContent()); } } @@ -348,7 +348,7 @@ bool addRRSIG(const testkeysset_t& keys, std::vector& records, const rec.d_name = records[recordsCount - 1].d_name; rec.d_ttl = records[recordsCount - 1].d_ttl; - rec.d_content = std::make_shared(rrc); + rec.setContent(std::make_shared(rrc)); records.push_back(rec); return true; @@ -367,7 +367,7 @@ void addDNSKEY(const testkeysset_t& keys, const DNSName& signer, uint32_t ttl, s rec.d_type = QType::DNSKEY; rec.d_ttl = ttl; - rec.d_content = std::make_shared(it->second.first.getDNSKEY()); + rec.setContent(std::make_shared(it->second.first.getDNSKEY())); records.push_back(rec); } @@ -383,7 +383,7 @@ bool addDS(const DNSName& domain, uint32_t ttl, std::vector& records, rec.d_type = QType::DS; rec.d_place = place; rec.d_ttl = ttl; - rec.d_content = std::make_shared(it->second.second); + rec.setContent(std::make_shared(it->second.second)); records.push_back(rec); return true; @@ -401,7 +401,7 @@ void addNSECRecordToLW(const DNSName& domain, const DNSName& next, const std::se rec.d_name = domain; rec.d_ttl = ttl; rec.d_type = QType::NSEC; - rec.d_content = std::make_shared(std::move(nrc)); + rec.setContent(std::make_shared(std::move(nrc))); rec.d_place = DNSResourceRecord::AUTHORITY; records.push_back(rec); @@ -423,7 +423,7 @@ void addNSEC3RecordToLW(const DNSName& hashedName, const std::string& hashedNext rec.d_name = hashedName; rec.d_ttl = ttl; rec.d_type = QType::NSEC3; - rec.d_content = std::make_shared(std::move(nrc)); + rec.setContent(std::make_shared(std::move(nrc))); rec.d_place = DNSResourceRecord::AUTHORITY; records.push_back(rec); diff --git a/pdns/recursordist/test-syncres_cc2.cc b/pdns/recursordist/test-syncres_cc2.cc index af5259a0b3a7..32372fe3e02e 100644 --- a/pdns/recursordist/test-syncres_cc2.cc +++ b/pdns/recursordist/test-syncres_cc2.cc @@ -1462,7 +1462,7 @@ BOOST_AUTO_TEST_CASE(test_flawed_nsset) /* we populate the cache with a flawed NSset, i.e. there is a NS entry but no corresponding glue */ time_t now = sr->getNow().tv_sec; std::vector records; - std::vector> sigs; + std::vector> sigs; addRecordToList(records, target, QType::NS, "pdns-public-ns1.powerdns.com.", DNSResourceRecord::AUTHORITY, now + 3600); g_recCache->replace(now, target, QType(QType::NS), records, sigs, vector>(), true, g_rootdnsname, boost::optional()); @@ -1568,7 +1568,7 @@ BOOST_AUTO_TEST_CASE(test_cache_hit) /* we populate the cache with everything we need */ time_t now = sr->getNow().tv_sec; std::vector records; - std::vector> sigs; + std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.1", DNSResourceRecord::ANSWER, now + 3600); g_recCache->replace(now, target, QType(QType::A), records, sigs, vector>(), true, g_rootdnsname, boost::optional()); @@ -1757,7 +1757,7 @@ BOOST_AUTO_TEST_CASE(test_cache_expired_ttl) const time_t now = sr->getNow().tv_sec; std::vector records; - std::vector> sigs; + std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.42", DNSResourceRecord::ANSWER, now - 60); g_recCache->replace(now - 3600, target, QType(QType::A), records, sigs, vector>(), true, g_rootdnsname, boost::optional()); @@ -1803,7 +1803,7 @@ BOOST_AUTO_TEST_CASE(test_cache_almost_expired_ttl) const time_t now = sr->getNow().tv_sec; std::vector records; - std::vector> sigs; + std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.2", DNSResourceRecord::ANSWER, now + 29); g_recCache->replace(now - 30, target, QType(QType::A), records, sigs, vector>(), true, g_rootdnsname, boost::optional()); diff --git a/pdns/recursordist/test-syncres_cc3.cc b/pdns/recursordist/test-syncres_cc3.cc index 1fe09133de6b..6f9b3bb4cb03 100644 --- a/pdns/recursordist/test-syncres_cc3.cc +++ b/pdns/recursordist/test-syncres_cc3.cc @@ -407,7 +407,7 @@ BOOST_AUTO_TEST_CASE(test_answer_no_aa) /* check that the record in the answer section has not been cached */ const ComboAddress who; vector cached; - vector> signatures; + vector> signatures; BOOST_REQUIRE_GT(g_recCache->get(now, target, QType(QType::A), MemRecursorCache::None, &cached, who, boost::none, &signatures), 0); } @@ -1279,7 +1279,7 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_oob) dr.d_name = target; dr.d_type = QType::A; dr.d_ttl = 1800; - dr.d_content = std::make_shared(targetAddr); + dr.setContent(std::make_shared(targetAddr)); ad.d_records.insert(dr); (*SyncRes::t_sstorage.domainmap)[authZone] = ad; @@ -1340,14 +1340,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_oob_cname) dr.d_name = target; dr.d_type = QType::CNAME; dr.d_ttl = 1800; - dr.d_content = std::make_shared(targetCname); + dr.setContent(std::make_shared(targetCname)); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = targetCname; dr.d_type = QType::A; dr.d_ttl = 1800; - dr.d_content = std::make_shared(targetCnameAddr); + dr.setContent(std::make_shared(targetCnameAddr)); ad.d_records.insert(dr); (*SyncRes::t_sstorage.domainmap)[authZone] = ad; @@ -1409,14 +1409,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone) dr.d_name = target; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = target; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(addr); + dr.setContent(std::make_shared(addr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -1458,14 +1458,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_cname_lead_to_oob) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = authZone; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(addr); + dr.setContent(std::make_shared(addr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -1514,14 +1514,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_oob_lead_to_outgoing_queryb) dr.d_name = target; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = target; dr.d_type = QType::CNAME; dr.d_ttl = 3600; - dr.d_content = std::make_shared(externalCNAME); + dr.setContent(std::make_shared(externalCNAME)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -1570,14 +1570,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_ds) dr.d_name = target; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.corp. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.corp. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = target; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(addr); + dr.setContent(std::make_shared(addr)); ad.d_records.insert(dr); auto map = std::make_shared(); diff --git a/pdns/recursordist/test-syncres_cc4.cc b/pdns/recursordist/test-syncres_cc4.cc index 01b10fa549ed..840ed3a497aa 100644 --- a/pdns/recursordist/test-syncres_cc4.cc +++ b/pdns/recursordist/test-syncres_cc4.cc @@ -23,14 +23,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_nodata) dr.d_name = target; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(ComboAddress("192.0.2.1")); + dr.setContent(std::make_shared(ComboAddress("192.0.2.1"))); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_nx) dr.d_name = DNSName("powerdns.com."); dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -111,21 +111,21 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_delegation) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("test.powerdns.com."); dr.d_type = QType::NS; dr.d_ttl = 3600; - dr.d_content = std::make_shared(ns); + dr.setContent(std::make_shared(ns)); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = ns; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(nsAddr); + dr.setContent(std::make_shared(nsAddr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -189,21 +189,21 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_delegation_point) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("test.powerdns.com."); dr.d_type = QType::NS; dr.d_ttl = 3600; - dr.d_content = std::make_shared(ns); + dr.setContent(std::make_shared(ns)); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = ns; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(nsAddr); + dr.setContent(std::make_shared(nsAddr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -249,14 +249,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_wildcard) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("*.powerdns.com."); dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(targetAddr); + dr.setContent(std::make_shared(targetAddr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -297,21 +297,21 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_wildcard_with_ent) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("abc.xyz.test.powerdns.com."); dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(targetAddr1); + dr.setContent(std::make_shared(targetAddr1)); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("*.powerdns.com."); dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(targetAddr2); + dr.setContent(std::make_shared(targetAddr2)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -354,14 +354,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_wildcard_nodata) dr.d_name = authZone; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("*.powerdns.com."); dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(targetAddr); + dr.setContent(std::make_shared(targetAddr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -400,14 +400,14 @@ BOOST_AUTO_TEST_CASE(test_auth_zone_cache_only) dr.d_name = target; dr.d_type = QType::SOA; dr.d_ttl = 3600; - dr.d_content = std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600"); + dr.setContent(std::make_shared("pdns-public-ns1.powerdns.com. pieter\\.lexis.powerdns.com. 2017032301 10800 3600 604800 3600")); ad.d_records.insert(dr); dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = target; dr.d_type = QType::A; dr.d_ttl = 3600; - dr.d_content = std::make_shared(addr); + dr.setContent(std::make_shared(addr)); ad.d_records.insert(dr); auto map = std::make_shared(); @@ -456,7 +456,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig) skeyset_t keyset; keyset.insert(std::make_shared(dpk.getDNSKEY())); - std::vector> sigs; + std::vector> sigs; sigs.push_back(std::make_shared(rrc)); BOOST_CHECK(validateWithKeySet(now, qname, recordcontents, sigs, keyset, std::nullopt) == vState::Secure); diff --git a/pdns/recursordist/test-syncres_cc8.cc b/pdns/recursordist/test-syncres_cc8.cc index 8c3eb4b9246e..49df518eebfa 100644 --- a/pdns/recursordist/test-syncres_cc8.cc +++ b/pdns/recursordist/test-syncres_cc8.cc @@ -15,14 +15,14 @@ BOOST_AUTO_TEST_CASE(test_nsec_denial_nowrap) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* No wrap test case: a.example.org. -> d.example.org. denies the existence of b.example.org. */ addNSECRecordToLW(DNSName("a.example.org."), DNSName("d.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_denial_nowrap) recordContents.clear(); signatureContents.clear(); addNSECRecordToLW(DNSName("example.org."), DNSName("+.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -64,14 +64,14 @@ BOOST_AUTO_TEST_CASE(test_nsec_denial_wrap_case_1) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* Wrap case 1 test case: z.example.org. -> b.example.org. denies the existence of a.example.org. */ addNSECRecordToLW(DNSName("z.example.org."), DNSName("b.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -100,14 +100,14 @@ BOOST_AUTO_TEST_CASE(test_nsec_denial_wrap_case_2) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* Wrap case 2 test case: y.example.org. -> a.example.org. denies the existence of z.example.org. */ addNSECRecordToLW(DNSName("y.example.org."), DNSName("a.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -136,14 +136,14 @@ BOOST_AUTO_TEST_CASE(test_nsec_denial_only_one_nsec) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* Only one NSEC in the whole zone test case: a.example.org. -> a.example.org. denies the existence of b.example.org. */ addNSECRecordToLW(DNSName("a.example.org."), DNSName("a.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -172,14 +172,14 @@ BOOST_AUTO_TEST_CASE(test_nsec_root_nxd_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* The RRSIG from "." denies the existence of anything between a. and c., including b. */ addNSECRecordToLW(DNSName("a."), DNSName("c."), {QType::NS}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_root_nxd_denial) recordContents.clear(); signatureContents.clear(); addNSECRecordToLW(DNSName("."), DNSName("+"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_ancestor_nxqtype_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* The RRSIG from "." denies the existence of any type except NS at a. @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_ancestor_nxqtype_denial) or a DS. */ addNSECRecordToLW(DNSName("a."), DNSName("b."), {QType::NS}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -269,10 +269,10 @@ BOOST_AUTO_TEST_CASE(test_nsec_ds_denial_from_child) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSECRecordToLW(DNSName("example.org."), DNSName("a.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_insecure_delegation_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* * RFC 5155 section 8.9: @@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_insecure_delegation_denial) we correctly detect that it's not. */ addNSECRecordToLW(DNSName("a."), DNSName("b."), {}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -342,7 +342,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_insecure_delegation_denial_soa) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* * RFC 5155 section 8.9: @@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_insecure_delegation_denial_soa) NS has to be set since it is proving an insecure delegation, but SOA should NOT! */ addNSECRecordToLW(DNSName("a."), DNSName("b."), {QType::NS, QType::SOA}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -382,10 +382,10 @@ BOOST_AUTO_TEST_CASE(test_nsec_nxqtype_cname) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSECRecordToLW(DNSName("a.powerdns.com."), DNSName("a.c.powerdns.com."), {QType::CNAME}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -411,10 +411,10 @@ BOOST_AUTO_TEST_CASE(test_nsec3_nxqtype_ds) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSEC3UnhashedRecordToLW(DNSName("powerdns.com."), DNSName("powerdns.com."), "whatever", {QType::A}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -441,10 +441,10 @@ BOOST_AUTO_TEST_CASE(test_nsec3_nxqtype_cname) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSEC3UnhashedRecordToLW(DNSName("a.powerdns.com."), DNSName("powerdns.com."), "whatever", {QType::CNAME}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -470,10 +470,10 @@ BOOST_AUTO_TEST_CASE(test_nsec_nxdomain_denial_missing_wildcard) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSECRecordToLW(DNSName("a.powerdns.com."), DNSName("d.powerdns.com"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -498,10 +498,10 @@ BOOST_AUTO_TEST_CASE(test_nsec3_nxdomain_denial_missing_wildcard) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSEC3NarrowRecordToLW(DNSName("a.powerdns.com."), DNSName("powerdns.com."), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records, 10); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -516,7 +516,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_nxdomain_denial_missing_wildcard) signatureContents.clear(); records.clear(); addNSEC3UnhashedRecordToLW(DNSName("powerdns.com."), DNSName("powerdns.com."), "whatever", {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records, 10); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -538,11 +538,11 @@ BOOST_AUTO_TEST_CASE(test_nsec_expanded_wildcard_proof) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* proves that a.example.com does exist, and has been generated from a wildcard (see the RRSIG below) */ addNSECRecordToLW(DNSName("a.example.org."), DNSName("d.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300, false, boost::none, DNSName("example.org.")); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -569,11 +569,11 @@ BOOST_AUTO_TEST_CASE(test_nsec_wildcard_with_cname) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* proves that b.example.com does not exist */ addNSECRecordToLW(DNSName("a.example.org."), DNSName("d.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -588,7 +588,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_wildcard_with_cname) recordContents.clear(); signatureContents.clear(); addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -608,7 +608,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_wildcard_with_cname) recordContents.clear(); signatureContents.clear(); addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::CNAME, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -635,11 +635,11 @@ BOOST_AUTO_TEST_CASE(test_nsec3_wildcard_with_cname) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* proves that b.example.com does not exist */ addNSEC3NarrowRecordToLW(DNSName("b.example.org"), DNSName("example.org."), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC3}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -654,7 +654,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_wildcard_with_cname) signatureContents.clear(); records.clear(); addNSEC3UnhashedRecordToLW(DNSName("example.org."), DNSName("example.org."), "whatever", {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -667,7 +667,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_wildcard_with_cname) signatureContents.clear(); records.clear(); addNSEC3UnhashedRecordToLW(DNSName("*.example.org."), DNSName("example.org"), "whatever", {QType::A, QType::TXT, QType::RRSIG, QType::NSEC3}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_wildcard_with_cname) signatureContents.clear(); records.clear(); addNSEC3UnhashedRecordToLW(DNSName("*.example.org."), DNSName("example.org"), "whatever", {QType::CNAME, QType::RRSIG, QType::NSEC3}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -713,10 +713,10 @@ BOOST_AUTO_TEST_CASE(test_nsec_ent_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; addNSECRecordToLW(DNSName("a.powerdns.com."), DNSName("a.c.powerdns.com."), {QType::A}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -745,7 +745,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_ent_denial) recordContents.clear(); signatureContents.clear(); addNSECRecordToLW(DNSName(").powerdns.com."), DNSName("+.powerdns.com."), {}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("powerdns.com."), 300); signatureContents.push_back(getRR(records.at(1))); records.clear(); @@ -772,7 +772,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ancestor_nxqtype_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* The RRSIG from "." denies the existence of any type except NS at a. @@ -781,7 +781,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ancestor_nxqtype_denial) be used to deny anything except the whole name or a DS. */ addNSEC3UnhashedRecordToLW(DNSName("a."), DNSName("."), "whatever", {QType::NS}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -813,7 +813,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ancestor_nxqtype_denial) signatureContents.clear(); records.clear(); addNSEC3NarrowRecordToLW(DNSName("sub.a."), DNSName("."), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC3}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ancestor_nxqtype_denial) signatureContents.clear(); records.clear(); addNSEC3NarrowRecordToLW(DNSName("*.a."), DNSName("."), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC3}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -852,11 +852,11 @@ BOOST_AUTO_TEST_CASE(test_nsec3_denial_too_many_iterations) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* adding a NSEC3 with more iterations that we support */ addNSEC3UnhashedRecordToLW(DNSName("a."), DNSName("."), "whatever", {QType::AAAA}, 600, records, g_maxNSEC3Iterations + 100); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -882,7 +882,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* * RFC 5155 section 8.9: @@ -897,7 +897,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial) we correctly detect that it's not. */ addNSEC3UnhashedRecordToLW(DNSName("a."), DNSName("."), "whatever", {}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -924,7 +924,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial_soa) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* * RFC 5155 section 8.9: @@ -938,7 +938,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial_soa) NS has to be set since it is proving an insecure delegation, but SOA should NOT! */ addNSEC3UnhashedRecordToLW(DNSName("a."), DNSName("."), "whatever", {QType::NS, QType::SOA}, 600, records); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -964,7 +964,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ent_opt_out) vector records; sortedRecords_t recordContents; - vector> signatureContents; + vector> signatureContents; /* * RFC 7129 section 5.1: @@ -979,7 +979,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ent_opt_out) a wildcard proof). */ addNSEC3UnhashedRecordToLW(DNSName("was.here."), DNSName("."), "whatever", {}, 600, records, 10, true /* opt out */); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -995,7 +995,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_ent_opt_out) signatureContents.clear(); records.clear(); addNSEC3NarrowRecordToLW(DNSName("ent.was.here."), DNSName("."), {QType::RRSIG, QType::NSEC3}, 600, records, 10, true /* opt-out */); - recordContents.insert(records.at(0).d_content); + recordContents.insert(records.at(0).getContent()); addRRSIG(keys, records, DNSName("."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -1197,7 +1197,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) /* check that the entry has not been cached for longer than the RRSIG validity */ const ComboAddress who; vector cached; - vector> signatures; + vector> signatures; BOOST_REQUIRE_EQUAL(g_recCache->get(tnow, target, QType(QType::A), MemRecursorCache::RequireAuth, &cached, who, boost::none, &signatures), 1); BOOST_REQUIRE_EQUAL(cached.size(), 1U); BOOST_REQUIRE_EQUAL(signatures.size(), 1U); diff --git a/pdns/recursordist/test-syncres_cc9.cc b/pdns/recursordist/test-syncres_cc9.cc index a16607bc9c31..bcf1be33a0d4 100644 --- a/pdns/recursordist/test-syncres_cc9.cc +++ b/pdns/recursordist/test-syncres_cc9.cc @@ -715,7 +715,7 @@ BOOST_AUTO_TEST_CASE(test_lowercase_outgoing) BOOST_CHECK_EQUAL(res, RCode::NoError); BOOST_REQUIRE_EQUAL(ret.size(), 2U); - BOOST_CHECK_EQUAL(ret[0].d_content->getZoneRepresentation(), cname.toString()); + BOOST_CHECK_EQUAL(ret[0].getContent()->getZoneRepresentation(), cname.toString()); BOOST_REQUIRE_EQUAL(sentOutQnames.size(), 4U); BOOST_CHECK_EQUAL(sentOutQnames[0].toString(), target.makeLowerCase().toString()); @@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(test_records_sanitization_keep_glue) /* check that we accepted the DS from the parent, and not from the child zone */ BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::DS), MemRecursorCache::None, &cached, who), 0); BOOST_REQUIRE_EQUAL(cached.size(), 1U); - BOOST_CHECK_EQUAL(cached.at(0).d_content->getZoneRepresentation(), "1 8 2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + BOOST_CHECK_EQUAL(cached.at(0).getContent()->getZoneRepresentation(), "1 8 2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); } BOOST_AUTO_TEST_CASE(test_records_sanitization_scrubs_ns_nxd) diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index c5ca3ccc66ea..b1d11ae170df 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -162,7 +162,7 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) {"name", dr.d_name.toString()}, {"type", DNSRecordContent::NumberToType(dr.d_type)}, {"ttl", (double)dr.d_ttl}, - {"content", dr.d_content->getZoneRepresentation()}}); + {"content", dr.getContent()->getZoneRepresentation()}}); } // id is the canonical lookup key, which doesn't actually match the name (in some cases) @@ -385,7 +385,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) const SyncRes::AuthDomain& zone = val.second; for (const SyncRes::AuthDomain::records_t::value_type& rr : zone.d_records) { - if (pdns_ci_find(rr.d_name.toString(), q) == string::npos && pdns_ci_find(rr.d_content->getZoneRepresentation(), q) == string::npos) + if (pdns_ci_find(rr.d_name.toString(), q) == string::npos && pdns_ci_find(rr.getContent()->getZoneRepresentation(), q) == string::npos) continue; doc.push_back(Json::object{ @@ -393,7 +393,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {"zone_id", zoneId}, {"zone_name", zoneName}, {"name", rr.d_name.toString()}, - {"content", rr.d_content->getZoneRepresentation()}}); + {"content", rr.getContent()->getZoneRepresentation()}}); } } resp->setJsonBody(doc); diff --git a/pdns/resolver.cc b/pdns/resolver.cc index ae29350e3f61..abdbff900754 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -217,7 +217,7 @@ namespace pdns { rr.qname = i.first.d_name; rr.qtype = i.first.d_type; rr.ttl = i.first.d_ttl; - rr.content = i.first.d_content->getZoneRepresentation(true); + rr.content = i.first.getContent()->getZoneRepresentation(true); result->push_back(rr); } @@ -287,14 +287,14 @@ bool Resolver::tryGetSOASerial(DNSName *domain, ComboAddress* remote, uint32_t * bool gotSOA=false; for(const MOADNSParser::answers_t::value_type& drc : mdp.d_answers) { if(drc.first.d_type == QType::SOA && drc.first.d_name == *domain) { - shared_ptr src=getRR(drc.first); + auto src = getRR(drc.first); if (src) { - *theirSerial=src->d_st.serial; + *theirSerial = src->d_st.serial; gotSOA = true; } } if(drc.first.d_type == QType::RRSIG && drc.first.d_name == *domain) { - shared_ptr rrc=getRR(drc.first); + auto rrc = getRR(drc.first); if(rrc && rrc->d_type == QType::SOA) { *theirInception= std::max(*theirInception, rrc->d_siginception); *theirExpire = std::max(*theirExpire, rrc->d_sigexpire); diff --git a/pdns/rfc2136handler.cc b/pdns/rfc2136handler.cc index ffce117ad860..ceeb2d3c6fd5 100644 --- a/pdns/rfc2136handler.cc +++ b/pdns/rfc2136handler.cc @@ -125,7 +125,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, if (rrType == QType::NSEC3PARAM) { g_log<d_content->getZoneRepresentation(), di->zone); + *ns3pr = NSEC3PARAMRecordContent(rr->getContent()->getZoneRepresentation(), di->zone); *narrow = false; // adding a NSEC3 will cause narrow mode to be dropped, as you cannot specify that in a NSEC3PARAM record d_dk.setNSEC3PARAM(di->zone, *ns3pr, (*narrow)); *haveNSEC3 = true; @@ -153,7 +153,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, SOAData sdOld, sdUpdate; DNSResourceRecord *oldRec = &rrset.front(); fillSOAData(oldRec->content, sdOld); - oldRec->setContent(rr->d_content->getZoneRepresentation()); + oldRec->setContent(rr->getContent()->getZoneRepresentation()); fillSOAData(oldRec->content, sdUpdate); if (rfc1982LessThan(sdOld.serial, sdUpdate.serial)) { di->backend->replaceRRSet(di->id, oldRec->qname, oldRec->qtype, rrset); @@ -168,9 +168,9 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, } else if (rrType == QType::CNAME) { int changedCNames = 0; for (auto& i : rrset) { - if (i.ttl != rr->d_ttl || i.content != rr->d_content->getZoneRepresentation()) { + if (i.ttl != rr->d_ttl || i.content != rr->getContent()->getZoneRepresentation()) { i.ttl = rr->d_ttl; - i.setContent(rr->d_content->getZoneRepresentation()); + i.setContent(rr->getContent()->getZoneRepresentation()); changedCNames++; } } @@ -192,7 +192,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, rrType.getCode() == QType::SRV) { lowerCase = true; } - string content = rr->d_content->getZoneRepresentation(); + string content = rr->getContent()->getZoneRepresentation(); if (lowerCase) content = toLower(content); for (auto& i : rrset) { string icontent = i.getZoneRepresentation(); @@ -371,7 +371,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, if (rr->d_class == QClass::ANY) d_dk.unsetNSEC3PARAM(rr->d_name); else if (rr->d_class == QClass::NONE) { - NSEC3PARAMRecordContent nsec3rr(rr->d_content->getZoneRepresentation(), di->zone); + NSEC3PARAMRecordContent nsec3rr(rr->getContent()->getZoneRepresentation(), di->zone); if (*haveNSEC3 && ns3pr->getZoneRepresentation() == nsec3rr.getZoneRepresentation()) d_dk.unsetNSEC3PARAM(rr->d_name); else @@ -410,8 +410,8 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, repr = rc->getZoneRepresentation(true); DLOG(g_log<d_content->getZoneRepresentation()=["<d_content->getZoneRepresentation()<<"]"<d_content->getZoneRepresentation()) + DLOG(g_log<getContent()->getZoneRepresentation()=["<getContent()->getZoneRepresentation()<<"]"<getContent()->getZoneRepresentation()) recordsToDelete.push_back(rec); else rrset.push_back(rec); @@ -956,7 +956,7 @@ int PacketHandler::processUpdate(DNSPacket& p) { if (nsRRInZone.size() > nsRRtoDelete.size()) { // only delete if the NS's we delete are less then what we have in the zone (3.4.2.4) for (auto& inZone: nsRRInZone) { for (auto& rr: nsRRtoDelete) { - if (inZone.getZoneRepresentation() == (rr)->d_content->getZoneRepresentation()) + if (inZone.getZoneRepresentation() == (rr)->getContent()->getZoneRepresentation()) changedRecords += performUpdate(msgPrefix, rr, &di, isPresigned, &narrow, &haveNSEC3, &ns3pr, &updatedSerial); } } diff --git a/pdns/saxfr.cc b/pdns/saxfr.cc index 9470ef44308a..fa2335e54094 100644 --- a/pdns/saxfr.cc +++ b/pdns/saxfr.cc @@ -145,7 +145,7 @@ try for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { if(i->first.d_type != QType::TKEY) continue; // recover TKEY record - tkrc = TKEYRecordContent(i->first.d_content->getZoneRepresentation()); + tkrc = TKEYRecordContent(i->first.getContent()->getZoneRepresentation()); input = tkrc.d_key; } } @@ -213,7 +213,7 @@ try if (!tsig) { std::cerr<<"Unexpected TSIG signature in data"<first.d_content->getZoneRepresentation()); + trc = TSIGRecordContent(i->first.getContent()->getZoneRepresentation()); continue; } if(i->first.d_type == QType::SOA) @@ -221,26 +221,26 @@ try ++soacount; } else if (i->first.d_type == QType::NSEC3PARAM) { - ns3pr = NSEC3PARAMRecordContent(i->first.d_content->getZoneRepresentation()); - isNSEC3 = true; + ns3pr = NSEC3PARAMRecordContent(i->first.getContent()->getZoneRepresentation()); + isNSEC3 = true; } ostringstream o; o<<"\t"<first.d_ttl<<"\tIN\t"<first.d_type); if(showdetails) { - o<<"\t"<first.d_content->getZoneRepresentation(); + o<<"\t"<first.getContent()->getZoneRepresentation(); } else if(i->first.d_type == QType::RRSIG) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); o<<"\t"<first.d_type == QType::NSEC3) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); o<<"\t"<first.d_type == QType::DNSKEY) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); o<<"\t"<first.d_content->getZoneRepresentation(); + o<<"\t"<first.getContent()->getZoneRepresentation(); } records.emplace_back(i->first.d_name, o.str()); diff --git a/pdns/sdig.cc b/pdns/sdig.cc index 848c4b48ccf6..87b4f558e471 100644 --- a/pdns/sdig.cc +++ b/pdns/sdig.cc @@ -124,12 +124,12 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails, << ttl(i->first.d_ttl) << "\t" << nameForClass(i->first.d_class, i->first.d_type) << "\t" << DNSRecordContent::NumberToType(i->first.d_type); if (dumpluaraw) { - cout<<"\t"<< makeLuaString(i->first.d_content->serialize(DNSName(), true))<first.getContent()->serialize(DNSName(), true))<first.d_class == QClass::IN) { if (i->first.d_type == QType::RRSIG) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout << "\t" << parts[0] << " " @@ -138,7 +138,7 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails, continue; } if (!showflags && i->first.d_type == QType::NSEC3) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout << "\t" << parts[0] << " [flags] " @@ -150,7 +150,7 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails, continue; } if (i->first.d_type == QType::DNSKEY) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout << "\t" << parts[0] << " " @@ -158,7 +158,7 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails, continue; } if (i->first.d_type == QType::SOA && hidesoadetails) { - string zoneRep = i->first.d_content->getZoneRepresentation(); + string zoneRep = i->first.getContent()->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout << "\t" << parts[0] << " " @@ -167,7 +167,7 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails, continue; } } - cout << "\t" << i->first.d_content->getZoneRepresentation() << "\n"; + cout << "\t" << i->first.getContent()->getZoneRepresentation() << "\n"; } EDNSOpts edo; diff --git a/pdns/serialtweaker.cc b/pdns/serialtweaker.cc index 3b85ae055b43..72f31a7d5809 100644 --- a/pdns/serialtweaker.cc +++ b/pdns/serialtweaker.cc @@ -170,7 +170,7 @@ DNSZoneRecord makeEditedDNSZRFromSOAData(DNSSECKeeper& dk, const SOAData& sd, DN soa.d_type = QType::SOA; soa.d_ttl = sd.ttl; soa.d_place = place; - soa.d_content = makeSOAContent(edited); + soa.setContent(makeSOAContent(edited)); DNSZoneRecord dzr; dzr.domain_id = sd.domain_id; diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 0198686d5c24..f740ae8bb7a8 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -100,12 +100,12 @@ namespace { bool dedupLessThan(const DNSZoneRecord& a, const DNSZoneRecord &b) { - return std::make_tuple(a.dr.d_content->getZoneRepresentation(), a.dr.d_ttl) < std::make_tuple(b.dr.d_content->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW + return std::make_tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) < std::make_tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW } bool dedupEqual(const DNSZoneRecord& a, const DNSZoneRecord &b) { - return std::make_tuple(a.dr.d_content->getZoneRepresentation(), a.dr.d_ttl) == std::make_tuple(b.dr.d_content->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW + return std::make_tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) == std::make_tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW } } diff --git a/pdns/sillyrecords.cc b/pdns/sillyrecords.cc index e66856e10383..cb97acc8fe49 100644 --- a/pdns/sillyrecords.cc +++ b/pdns/sillyrecords.cc @@ -168,7 +168,7 @@ std::shared_ptr LOCRecordContent::make(const string& content) } -void LOCRecordContent::toPacket(DNSPacketWriter& pw) +void LOCRecordContent::toPacket(DNSPacketWriter& pw) const { pw.xfr8BitInt(d_version); pw.xfr8BitInt(d_size); diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index a60d12dfead3..e4a1ffc8d0cc 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -449,7 +449,7 @@ void CommunicatorClass::ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, c st.serial=di.serial; DNSRecord drsoa; - drsoa.d_content = std::make_shared(g_rootdnsname, g_rootdnsname, st); + drsoa.setContent(std::make_shared(g_rootdnsname, g_rootdnsname, st)); auto deltas = getIXFRDeltas(remote, domain, drsoa, xfrTimeout, false, tt, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024); zs.numDeltas=deltas.size(); // cout<<"Got "<getZoneRepresentation()<getZoneRepresentation()<& q, continue; } zrr.dr.d_type = QType::DNSKEY; - zrr.dr.d_content = std::make_shared(value.first.getDNSKEY()); + zrr.dr.setContent(std::make_shared(value.first.getDNSKEY())); DNSName keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, zrr.dr.d_name))) : zrr.dr.d_name; zrrs.push_back(zrr); @@ -730,10 +730,10 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, zrr.dr.d_type=QType::CDNSKEY; if (publishCDNSKEY == "0") { doCDNSKEY = false; - zrr.dr.d_content=PacketHandler::s_deleteCDNSKEYContent; + zrr.dr.setContent(PacketHandler::s_deleteCDNSKEYContent); zrrs.push_back(zrr); } else { - zrr.dr.d_content = std::make_shared(value.first.getDNSKEY()); + zrr.dr.setContent(std::make_shared(value.first.getDNSKEY())); zrrs.push_back(zrr); } } @@ -744,11 +744,11 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, stringtok(digestAlgos, publishCDS, ", "); if(std::find(digestAlgos.begin(), digestAlgos.end(), "0") != digestAlgos.end()) { doCDS = false; - zrr.dr.d_content=PacketHandler::s_deleteCDSContent; + zrr.dr.setContent(PacketHandler::s_deleteCDSContent); zrrs.push_back(zrr); } else { for(auto const &digestAlgo : digestAlgos) { - zrr.dr.d_content=std::make_shared(makeDSFromDNSKey(target, value.first.getDNSKEY(), pdns::checked_stoi(digestAlgo))); + zrr.dr.setContent(std::make_shared(makeDSFromDNSKey(target, value.first.getDNSKEY(), pdns::checked_stoi(digestAlgo)))); zrrs.push_back(zrr); } } @@ -762,7 +762,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, uint8_t flags = ns3pr.d_flags; zrr.dr.d_type = QType::NSEC3PARAM; ns3pr.d_flags = 0; - zrr.dr.d_content = std::make_shared(ns3pr); + zrr.dr.setContent(std::make_shared(ns3pr)); ns3pr.d_flags = flags; DNSName keyname = DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, zrr.dr.d_name))); zrrs.push_back(zrr); @@ -782,7 +782,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, zrr.dr.d_name = target; zrr.dr.d_ttl = 0; zrr.dr.d_type = QType::NS; - zrr.dr.d_content = std::make_shared("invalid."); + zrr.dr.setContent(std::make_shared("invalid.")); zrrs.emplace_back(zrr); } @@ -825,17 +825,17 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, if(zrr.dr.d_name.isPartOf(target)) { if (zrr.dr.d_type == QType::ALIAS && ::arg().mustDo("outgoing-axfr-expand-alias")) { vector ips; - int ret1 = stubDoResolve(getRR(zrr.dr)->d_content, QType::A, ips); - int ret2 = stubDoResolve(getRR(zrr.dr)->d_content, QType::AAAA, ips); + int ret1 = stubDoResolve(getRR(zrr.dr)->getContent(), QType::A, ips); + int ret2 = stubDoResolve(getRR(zrr.dr)->getContent(), QType::AAAA, ips); if(ret1 != RCode::NoError || ret2 != RCode::NoError) { - g_log<getZoneRepresentation()<<", aborting AXFR"<getZoneRepresentation()<<", aborting AXFR"<setRcode(RCode::ServFail); sendPacket(outpacket,outsock); return 0; } - for(const auto& ip: ips) { + for (auto& ip: ips) { zrr.dr.d_type = ip.dr.d_type; - zrr.dr.d_content = ip.dr.d_content; + zrr.dr.setContent(ip.dr.getContent()); zrrs.push_back(zrr); } continue; @@ -858,7 +858,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, } } - for (auto loopRR : zrrs) { + for (auto& loopRR : zrrs) { if ((loopRR.dr.d_type == QType::SVCB || loopRR.dr.d_type == QType::HTTPS)) { // Process auto hints // TODO this is an almost copy of the code in the packethandler @@ -866,8 +866,12 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, if (rrc == nullptr) { continue; } - DNSName svcTarget = rrc->getTarget().isRoot() ? loopRR.dr.d_name : rrc->getTarget(); - if (rrc->autoHint(SvcParam::ipv4hint)) { + auto newRRC = rrc->clone(); + if (!newRRC) { + continue; + } + DNSName svcTarget = newRRC->getTarget().isRoot() ? loopRR.dr.d_name : newRRC->getTarget(); + if (newRRC->autoHint(SvcParam::ipv4hint)) { sd.db->lookup(QType::A, svcTarget, sd.domain_id); vector hints; DNSZoneRecord rr; @@ -876,13 +880,13 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, hints.push_back(arrc->getCA()); } if (hints.size() == 0) { - rrc->removeParam(SvcParam::ipv4hint); + newRRC->removeParam(SvcParam::ipv4hint); } else { - rrc->setHints(SvcParam::ipv4hint, hints); + newRRC->setHints(SvcParam::ipv4hint, hints); } } - if (rrc->autoHint(SvcParam::ipv6hint)) { + if (newRRC->autoHint(SvcParam::ipv6hint)) { sd.db->lookup(QType::AAAA, svcTarget, sd.domain_id); vector hints; DNSZoneRecord rr; @@ -891,11 +895,13 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, hints.push_back(arrc->getCA()); } if (hints.size() == 0) { - rrc->removeParam(SvcParam::ipv6hint); + newRRC->removeParam(SvcParam::ipv6hint); } else { - rrc->setHints(SvcParam::ipv6hint, hints); + newRRC->setHints(SvcParam::ipv6hint, hints); } } + + loopRR.dr.setContent(std::move(newRRC)); } } @@ -1061,7 +1067,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, zrr.dr.d_name = iter->first+sd.qname; zrr.dr.d_ttl = sd.getNegativeTTL(); - zrr.dr.d_content = std::make_shared(std::move(n3rc)); + zrr.dr.setContent(std::make_shared(std::move(n3rc))); zrr.dr.d_type = QType::NSEC3; zrr.dr.d_place = DNSResourceRecord::ANSWER; zrr.auth=true; @@ -1095,7 +1101,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, zrr.dr.d_name = iter->first; zrr.dr.d_ttl = sd.getNegativeTTL(); - zrr.dr.d_content = std::make_shared(std::move(nrc)); + zrr.dr.setContent(std::make_shared(std::move(nrc))); zrr.dr.d_type = QType::NSEC; zrr.dr.d_place = DNSResourceRecord::ANSWER; zrr.auth=true; @@ -1172,7 +1178,7 @@ int TCPNameserver::doIXFR(std::unique_ptr& q, int outsock) const DNSRecord *rr = &answer.first; if (rr->d_type == QType::SOA && rr->d_place == DNSResourceRecord::AUTHORITY) { vectorparts; - stringtok(parts, rr->d_content->getZoneRepresentation()); + stringtok(parts, rr->getContent()->getZoneRepresentation()); if (parts.size() >= 3) { try { pdns::checked_stoi_into(serial, parts[2]); diff --git a/pdns/test-common.hh b/pdns/test-common.hh index 50de3b7ec094..8436fca44029 100644 --- a/pdns/test-common.hh +++ b/pdns/test-common.hh @@ -36,7 +36,7 @@ static inline void addRecordToList(std::vector& records, const DNSNam rec.d_type = type; rec.d_ttl = ttl; - rec.d_content = getRecordContent(type, content); + rec.setContent(getRecordContent(type, content)); records.push_back(rec); } diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 5b931945eb13..141cfc3f9eed 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -697,7 +697,7 @@ BOOST_AUTO_TEST_CASE(test_nsec3_records_types) { const auto& record = parser.d_answers.at(0).first; BOOST_REQUIRE(record.d_type == QType::NSEC3); BOOST_REQUIRE(record.d_class == QClass::IN); - auto content = std::dynamic_pointer_cast(record.d_content); + auto content = getRR(record); BOOST_REQUIRE(content); BOOST_CHECK_EQUAL(content->numberOfTypesSet(), 0U); for (size_t idx = 0; idx < 65536; idx++) { diff --git a/pdns/test-tsig.cc b/pdns/test-tsig.cc index c3231c04860d..8dc1ac868baa 100644 --- a/pdns/test-tsig.cc +++ b/pdns/test-tsig.cc @@ -85,7 +85,7 @@ static void checkTSIG(const DNSName& tsigName, const DNSName& tsigAlgo, const st BOOST_CHECK_EQUAL(answer.first.d_ttl, 0U); BOOST_CHECK_EQUAL(tsigFound, false); - shared_ptr rectrc = getRR(answer.first); + auto rectrc = getRR(answer.first); if (rectrc) { trc = *rectrc; theirMac = rectrc->d_mac; diff --git a/pdns/tkey.cc b/pdns/tkey.cc index 7fdd540229f7..a057b196d59c 100644 --- a/pdns/tkey.cc +++ b/pdns/tkey.cc @@ -26,11 +26,12 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr& return; } + auto inception = time(nullptr); // retain original name for response tkey_out->d_error = 0; tkey_out->d_mode = tkey_in.d_mode; tkey_out->d_algo = tkey_in.d_algo; - tkey_out->d_inception = time((time_t*)nullptr); + tkey_out->d_inception = inception; tkey_out->d_expiration = tkey_out->d_inception+15; if (tkey_in.d_mode == 3) { // establish context @@ -107,7 +108,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr& zrr.dr.d_ttl = 0; zrr.dr.d_type = QType::TKEY; zrr.dr.d_class = QClass::ANY; - zrr.dr.d_content = tkey_out; + zrr.dr.setContent(std::move(tkey_out)); zrr.dr.d_place = DNSResourceRecord::ANSWER; r->addRecord(std::move(zrr)); @@ -116,7 +117,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr& { TSIGRecordContent trc; trc.d_algoName = DNSName("gss-tsig"); - trc.d_time = tkey_out->d_inception; + trc.d_time = inception; trc.d_fudge = 300; trc.d_mac = ""; trc.d_origID = p.d.id; diff --git a/pdns/tsigverifier.cc b/pdns/tsigverifier.cc index de0471b73dde..05e7b2a3f6c2 100644 --- a/pdns/tsigverifier.cc +++ b/pdns/tsigverifier.cc @@ -28,7 +28,7 @@ bool TSIGTCPVerifier::check(const string& data, const MOADNSParser& mdp) } if(answer.first.d_type == QType::TSIG) { - shared_ptr trc = getRR(answer.first); + auto trc = getRR(answer.first); if(trc) { theirMac = trc->d_mac; d_trc.d_time = trc->d_time; diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index cc7621b3738c..6392adb25d49 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -444,7 +444,7 @@ bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* s DNSZoneRecord rr; rr.dr.d_name = sd->qname; rr.dr.d_type = QType::SOA; - rr.dr.d_content = makeSOAContent(*sd); + rr.dr.setContent(makeSOAContent(*sd)); rr.dr.d_ttl = sd->ttl; rr.domain_id = sd->domain_id; @@ -480,7 +480,7 @@ bool UeberBackend::getSOAUncached(const DNSName &domain, SOAData &sd) DNSZoneRecord rr; rr.dr.d_name = sd.qname; rr.dr.d_type = QType::SOA; - rr.dr.d_content = makeSOAContent(sd); + rr.dr.setContent(makeSOAContent(sd)); rr.dr.d_ttl = sd.ttl; rr.domain_id = sd.domain_id; diff --git a/pdns/validate.cc b/pdns/validate.cc index b37cebaec19c..da16c70b0e33 100644 --- a/pdns/validate.cc +++ b/pdns/validate.cc @@ -30,9 +30,9 @@ static bool isRevokedKey(const DNSKEYRecordContent& key) return (key.d_flags & 128) != 0; } -static vector > getByTag(const skeyset_t& keys, uint16_t tag, uint8_t algorithm, const OptLog& log) +static vector > getByTag(const skeyset_t& keys, uint16_t tag, uint8_t algorithm, const OptLog& log) { - vector> ret; + vector> ret; for (const auto& key : keys) { if (!isAZoneKey(*key)) { @@ -88,7 +88,7 @@ static bool nsecProvesENT(const DNSName& name, const DNSName& begin, const DNSNa using nsec3HashesCache = std::map, std::string>; -static std::string getHashFromNSEC3(const DNSName& qname, const std::shared_ptr& nsec3, nsec3HashesCache& cache) +static std::string getHashFromNSEC3(const DNSName& qname, const std::shared_ptr& nsec3, nsec3HashesCache& cache) { std::string result; @@ -163,7 +163,7 @@ bool denialProvesNoDelegation(const DNSName& zone, const std::vector& Labels field of the covering RRSIG RR, then the RRset and its covering RRSIG RR were created as a result of wildcard expansion." */ -bool isWildcardExpanded(unsigned int labelCount, const std::shared_ptr& sign) +bool isWildcardExpanded(unsigned int labelCount, const std::shared_ptr& sign) { if (sign && sign->d_labels < labelCount) { return true; @@ -172,7 +172,7 @@ bool isWildcardExpanded(unsigned int labelCount, const std::shared_ptr >& signatures) +static bool isWildcardExpanded(const DNSName& owner, const std::vector >& signatures) { if (signatures.empty()) { return false; @@ -183,7 +183,7 @@ static bool isWildcardExpanded(const DNSName& owner, const std::vector& sign) +bool isWildcardExpandedOntoItself(const DNSName& owner, unsigned int labelCount, const std::shared_ptr& sign) { if (owner.isWildcard() && (labelCount - 1) == sign->d_labels) { /* this is a wildcard alright, but it has not been expanded */ @@ -192,7 +192,7 @@ bool isWildcardExpandedOntoItself(const DNSName& owner, unsigned int labelCount, return false; } -static bool isWildcardExpandedOntoItself(const DNSName& owner, const std::vector >& signatures) +static bool isWildcardExpandedOntoItself(const DNSName& owner, const std::vector >& signatures) { if (signatures.empty()) { return false; @@ -205,7 +205,7 @@ static bool isWildcardExpandedOntoItself(const DNSName& owner, const std::vector /* if this is a wildcard NSEC, the owner name has been modified to match the name. Make sure we use the original '*' form. */ -DNSName getNSECOwnerName(const DNSName& initialOwner, const std::vector >& signatures) +DNSName getNSECOwnerName(const DNSName& initialOwner, const std::vector >& signatures) { DNSName result = initialOwner; @@ -228,14 +228,14 @@ DNSName getNSECOwnerName(const DNSName& initialOwner, const std::vector& nsec) +static bool isNSECAncestorDelegation(const DNSName& signer, const DNSName& owner, const std::shared_ptr& nsec) { return nsec->isSet(QType::NS) && !nsec->isSet(QType::SOA) && signer.countLabels() < owner.countLabels(); } -bool isNSEC3AncestorDelegation(const DNSName& signer, const DNSName& owner, const std::shared_ptr& nsec3) +bool isNSEC3AncestorDelegation(const DNSName& signer, const DNSName& owner, const std::shared_ptr& nsec3) { return nsec3->isSet(QType::NS) && !nsec3->isSet(QType::SOA) && @@ -251,7 +251,7 @@ static bool provesNoDataWildCard(const DNSName& qname, const uint16_t qtype, con if (v.first.second == QType::NSEC) { for (const auto& r : v.second.records) { VLOG(log, ":\t"<getZoneRepresentation()<(r); + auto nsec = std::dynamic_pointer_cast(r); if (!nsec) { continue; } @@ -298,7 +298,7 @@ static bool provesNoWildCard(const DNSName& qname, const uint16_t qtype, const D if (v.first.second == QType::NSEC) { for (const auto& r : v.second.records) { VLOG(log, qname << ":\t"<getZoneRepresentation()<(r); + auto nsec = std::dynamic_pointer_cast(r); if (!nsec) { continue; } @@ -347,7 +347,7 @@ static bool provesNSEC3NoWildCard(const DNSName& closestEncloser, uint16_t const if (v.first.second == QType::NSEC3) { for (const auto& r : v.second.records) { VLOG(log, closestEncloser << ":\t"<getZoneRepresentation()<(r); + auto nsec3 = std::dynamic_pointer_cast(r); if (!nsec3) { continue; } @@ -402,7 +402,7 @@ static bool provesNSEC3NoWildCard(const DNSName& closestEncloser, uint16_t const return false; } -dState matchesNSEC(const DNSName& name, uint16_t qtype, const DNSName& nsecOwner, const std::shared_ptr& nsec, const std::vector>& signatures, const OptLog& log) +dState matchesNSEC(const DNSName& name, uint16_t qtype, const DNSName& nsecOwner, const std::shared_ptr& nsec, const std::vector>& signatures, const OptLog& log) { const DNSName signer = getSigner(signatures); if (!name.isPartOf(signer) || !nsecOwner.isPartOf(signer)) { @@ -499,7 +499,7 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 continue; } - auto nsec = std::dynamic_pointer_cast(r); + auto nsec = std::dynamic_pointer_cast(r); if (!nsec) { continue; } @@ -642,7 +642,7 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 } else if(v.first.second==QType::NSEC3) { for (const auto& r : v.second.records) { VLOG(log, qname << ":\t"<getZoneRepresentation()<(r); + auto nsec3 = std::dynamic_pointer_cast(r); if (!nsec3) { continue; } @@ -747,7 +747,7 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 if(v.first.second==QType::NSEC3) { for(const auto& r : v.second.records) { VLOG(log, qname << ":\t"<getZoneRepresentation()<(r); + auto nsec3 = std::dynamic_pointer_cast(r); if (!nsec3) { continue; } @@ -831,7 +831,7 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 if(v.first.second==QType::NSEC3) { for(const auto& r : v.second.records) { VLOG(log, qname << ":\t"<getZoneRepresentation()<(r); + auto nsec3 = std::dynamic_pointer_cast(r); if(!nsec3) continue; @@ -896,19 +896,19 @@ dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16 return dState::NODENIAL; } -bool isRRSIGNotExpired(const time_t now, const shared_ptr& sig) +bool isRRSIGNotExpired(const time_t now, const shared_ptr& sig) { // Should use https://www.rfc-editor.org/rfc/rfc4034.txt section 3.1.5 return sig->d_sigexpire >= now; } -bool isRRSIGIncepted(const time_t now, const shared_ptr& sig) +bool isRRSIGIncepted(const time_t now, const shared_ptr& sig) { // Should use https://www.rfc-editor.org/rfc/rfc4034.txt section 3.1.5 return sig->d_siginception - g_signatureInceptionSkew <= now; } -static bool checkSignatureWithKey(const DNSName& qname, time_t now, const shared_ptr sig, const shared_ptr key, const std::string& msg, vState& ede, const OptLog& log) +static bool checkSignatureWithKey(const DNSName& qname, time_t now, const shared_ptr& sig, const shared_ptr& key, const std::string& msg, vState& ede, const OptLog& log) { bool result = false; try { @@ -936,7 +936,7 @@ static bool checkSignatureWithKey(const DNSName& qname, time_t now, const shared return result; } -vState validateWithKeySet(time_t now, const DNSName& name, const sortedRecords_t& toSign, const vector >& signatures, const skeyset_t& keys, const OptLog& log, bool validateAllSigs) +vState validateWithKeySet(time_t now, const DNSName& name, const sortedRecords_t& toSign, const vector >& signatures, const skeyset_t& keys, const OptLog& log, bool validateAllSigs) { bool foundKey = false; bool isValid = false; @@ -1023,7 +1023,7 @@ cspmap_t harvestCSPFromRecs(const vector& recs) } } else { - cspmap[{rec.d_name, rec.d_type}].records.insert(rec.d_content); + cspmap[{rec.d_name, rec.d_type}].records.insert(rec.getContent()); } } return cspmap; @@ -1053,7 +1053,7 @@ bool haveNegativeTrustAnchor(const map& negAnchors, const D return true; } -vState validateDNSKeysAgainstDS(time_t now, const DNSName& zone, const dsmap_t& dsmap, const skeyset_t& tkeys, const sortedRecords_t& toSign, const vector >& sigs, skeyset_t& validkeys, const OptLog& log) +vState validateDNSKeysAgainstDS(time_t now, const DNSName& zone, const dsmap_t& dsmap, const skeyset_t& tkeys, const sortedRecords_t& toSign, const vector >& sigs, skeyset_t& validkeys, const OptLog& log) { /* * Check all DNSKEY records against all DS records and place all DNSKEY records @@ -1204,7 +1204,7 @@ bool isSupportedDS(const DSRecordContent& ds, const OptLog& log) return true; } -DNSName getSigner(const std::vector >& signatures) +DNSName getSigner(const std::vector >& signatures) { for (const auto& sig : signatures) { if (sig) { diff --git a/pdns/validate.hh b/pdns/validate.hh index 3226c2c3d8a0..0f829bedcd63 100644 --- a/pdns/validate.hh +++ b/pdns/validate.hh @@ -56,7 +56,7 @@ public: struct ContentSigPair { sortedRecords_t records; - vector> signatures; + vector> signatures; // ponder adding a validate method that accepts a key }; typedef map, ContentSigPair> cspmap_t; @@ -64,37 +64,37 @@ typedef std::set dsmap_t; struct sharedDNSKeyRecordContentCompare { - bool operator() (const shared_ptr& a, const shared_ptr& b) const + bool operator() (const shared_ptr& a, const shared_ptr& b) const { return *a < *b; } }; -typedef set, sharedDNSKeyRecordContentCompare > skeyset_t; +typedef set, sharedDNSKeyRecordContentCompare > skeyset_t; -vState validateWithKeySet(time_t now, const DNSName& name, const sortedRecords_t& records, const vector >& signatures, const skeyset_t& keys, const OptLog& log, bool validateAllSigs=true); +vState validateWithKeySet(time_t now, const DNSName& name, const sortedRecords_t& records, const vector >& signatures, const skeyset_t& keys, const OptLog& log, bool validateAllSigs=true); bool isCoveredByNSEC(const DNSName& name, const DNSName& begin, const DNSName& next); bool isCoveredByNSEC3Hash(const std::string& h, const std::string& beginHash, const std::string& nextHash); bool isCoveredByNSEC3Hash(const DNSName& h, const DNSName& beginHash, const DNSName& nextHash); cspmap_t harvestCSPFromRecs(const vector& recs); bool getTrustAnchor(const map& anchors, const DNSName& zone, dsmap_t &res); bool haveNegativeTrustAnchor(const map& negAnchors, const DNSName& zone, std::string& reason); -vState validateDNSKeysAgainstDS(time_t now, const DNSName& zone, const dsmap_t& dsmap, const skeyset_t& tkeys, const sortedRecords_t& toSign, const vector >& sigs, skeyset_t& validkeys, const OptLog&); +vState validateDNSKeysAgainstDS(time_t now, const DNSName& zone, const dsmap_t& dsmap, const skeyset_t& tkeys, const sortedRecords_t& toSign, const vector >& sigs, skeyset_t& validkeys, const OptLog&); dState getDenial(const cspmap_t &validrrsets, const DNSName& qname, const uint16_t qtype, bool referralToUnsigned, bool wantsNoDataProof, const OptLog& log = std::nullopt, bool needsWildcardProof=true, unsigned int wildcardLabelsCount=0); bool isSupportedDS(const DSRecordContent& ds, const OptLog&); -DNSName getSigner(const std::vector >& signatures); +DNSName getSigner(const std::vector >& signatures); bool denialProvesNoDelegation(const DNSName& zone, const std::vector& dsrecords); -bool isRRSIGNotExpired(const time_t now, const std::shared_ptr& sig); -bool isRRSIGIncepted(const time_t now, const shared_ptr& sig); -bool isWildcardExpanded(unsigned int labelCount, const std::shared_ptr& sign); -bool isWildcardExpandedOntoItself(const DNSName& owner, unsigned int labelCount, const std::shared_ptr& sign); +bool isRRSIGNotExpired(const time_t now, const std::shared_ptr& sig); +bool isRRSIGIncepted(const time_t now, const shared_ptr& sig); +bool isWildcardExpanded(unsigned int labelCount, const std::shared_ptr& sign); +bool isWildcardExpandedOntoItself(const DNSName& owner, unsigned int labelCount, const std::shared_ptr& sign); void updateDNSSECValidationState(vState& state, const vState stateUpdate); -dState matchesNSEC(const DNSName& name, uint16_t qtype, const DNSName& nsecOwner, const std::shared_ptr& nsec, const std::vector>& signatures, const OptLog&); +dState matchesNSEC(const DNSName& name, uint16_t qtype, const DNSName& nsecOwner, const std::shared_ptr& nsec, const std::vector>& signatures, const OptLog&); -bool isNSEC3AncestorDelegation(const DNSName& signer, const DNSName& owner, const std::shared_ptr& nsec3); -DNSName getNSECOwnerName(const DNSName& initialOwner, const std::vector >& signatures); +bool isNSEC3AncestorDelegation(const DNSName& signer, const DNSName& owner, const std::shared_ptr& nsec3); +DNSName getNSECOwnerName(const DNSName& initialOwner, const std::vector >& signatures); DNSName getClosestEncloserFromNSEC(const DNSName& name, const DNSName& owner, const DNSName& next); template bool isTypeDenied(const NSEC& nsec, const QType& type) diff --git a/pdns/zonemd.cc b/pdns/zonemd.cc index 0688323ac275..89cec85aa3b8 100644 --- a/pdns/zonemd.cc +++ b/pdns/zonemd.cc @@ -25,7 +25,7 @@ void pdns::ZoneMD::readRecords(ZoneParserTNG& zpt) } DNSRecord rec; rec.d_name = dnsResourceRecord.qname; - rec.d_content = drc; + rec.setContent(std::move(drc)); rec.d_type = dnsResourceRecord.qtype; rec.d_class = dnsResourceRecord.qclass; rec.d_ttl = dnsResourceRecord.ttl; @@ -53,14 +53,14 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) if (record.d_class == QClass::IN && record.d_name == d_zone) { switch (record.d_type) { case QType::SOA: { - d_soaRecordContent = std::dynamic_pointer_cast(record.d_content); + d_soaRecordContent = getRR(record); if (d_soaRecordContent == nullptr) { throw PDNSException("Invalid SOA record"); } break; } case QType::DNSKEY: { - auto dnskey = std::dynamic_pointer_cast(record.d_content); + auto dnskey = getRR(record); if (dnskey == nullptr) { throw PDNSException("Invalid DNSKEY record"); } @@ -68,7 +68,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) break; } case QType::ZONEMD: { - auto zonemd = std::dynamic_pointer_cast(record.d_content); + auto zonemd = getRR(record); if (zonemd == nullptr) { throw PDNSException("Invalid ZONEMD record"); } @@ -80,7 +80,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) break; } case QType::RRSIG: { - auto rrsig = std::dynamic_pointer_cast(record.d_content); + auto rrsig = getRR(record); if (rrsig == nullptr) { throw PDNSException("Invalid RRSIG record"); } @@ -92,7 +92,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) break; } case QType::NSEC: { - auto nsec = std::dynamic_pointer_cast(record.d_content); + auto nsec = getRR(record); if (nsec == nullptr) { throw PDNSException("Invalid NSEC record"); } @@ -103,7 +103,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) // Handled below break; case QType::NSEC3PARAM: { - auto param = std::dynamic_pointer_cast(record.d_content); + auto param = getRR(record); if (param == nullptr) { throw PDNSException("Invalid NSEC3PARAM record"); } @@ -130,7 +130,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) if (record.d_class == QClass::IN && (d_nsec3label.empty() || record.d_name == d_nsec3label)) { switch (record.d_type) { case QType::NSEC3: { - auto nsec3 = std::dynamic_pointer_cast(record.d_content); + auto nsec3 = getRR(record); if (nsec3 == nullptr) { throw PDNSException("Invalid NSEC3 record"); } @@ -138,7 +138,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) break; } case QType::RRSIG: { - auto rrsig = std::dynamic_pointer_cast(record.d_content); + auto rrsig = getRR(record); if (rrsig == nullptr) { throw PDNSException("Invalid RRSIG record"); } @@ -150,7 +150,7 @@ void pdns::ZoneMD::readRecord(const DNSRecord& record) } } RRSetKey_t key = std::pair(record.d_name, record.d_type); - d_resourceRecordSets[key].push_back(record.d_content); + d_resourceRecordSets[key].push_back(record.getContent()); d_resourceRecordSetTTLs[key] = record.d_ttl; } @@ -218,7 +218,7 @@ void pdns::ZoneMD::verify(bool& validationDone, bool& validationOK) sortedRecords_t sorted; for (auto& rr : rrset.second) { if (qtype == QType::RRSIG) { - const auto rrsig = std::dynamic_pointer_cast(rr); + const auto rrsig = std::dynamic_pointer_cast(rr); if (rrsig->d_type == QType::ZONEMD && qname == d_zone) { continue; } @@ -241,7 +241,7 @@ void pdns::ZoneMD::verify(bool& validationDone, bool& validationOK) // RRSIG is special, since original TTL depends on qtype covered by RRSIG // which can be different per record for (const auto& rrsig : sorted) { - auto rrsigc = std::dynamic_pointer_cast(rrsig); + auto rrsigc = std::dynamic_pointer_cast(rrsig); RRSIGRecordContent rrc; rrc.d_originalttl = d_resourceRecordSetTTLs[pair(rrset.first.first, rrsigc->d_type)]; rrc.d_type = qtype; diff --git a/pdns/zonemd.hh b/pdns/zonemd.hh index acb402d2503b..3f20d52eaceb 100644 --- a/pdns/zonemd.hh +++ b/pdns/zonemd.hh @@ -59,21 +59,21 @@ public: void verify(bool& validationDone, bool& validationOK); // Return the zone's apex DNSKEYs - const std::set>& getDNSKEYs() const + const std::set>& getDNSKEYs() const { return d_dnskeys; } // Return the zone's apex RRSIGs - const std::vector>& getRRSIGs() const + const std::vector>& getRRSIGs() const { return d_rrsigs; } // Return the zone's apex ZONEMDs - std::vector> getZONEMDs() const + std::vector> getZONEMDs() const { - std::vector> ret; + std::vector> ret; for (const auto& zonemd : d_zonemdRecords) { ret.emplace_back(zonemd.second.record); } @@ -98,14 +98,14 @@ public: return d_nsec3label; } - const std::vector>& getNSEC3Params() const + const std::vector>& getNSEC3Params() const { return d_nsec3params; } private: - typedef std::pair RRSetKey_t; - typedef std::vector> RRVector_t; + using RRSetKey_t = std::pair; + using RRVector_t = std::vector>; struct CanonRRSetKeyCompare { @@ -122,11 +122,11 @@ private: } }; - typedef std::map RRSetMap_t; + using RRSetMap_t = std::map; struct ZoneMDAndDuplicateFlag { - std::shared_ptr record; + const std::shared_ptr record; bool duplicate; }; @@ -136,10 +136,10 @@ private: RRSetMap_t d_resourceRecordSets; std::map d_resourceRecordSetTTLs; - std::shared_ptr d_soaRecordContent; - std::set> d_dnskeys; - std::vector> d_rrsigs; - std::vector> d_nsec3params; + std::shared_ptr d_soaRecordContent; + std::set> d_dnskeys; + std::vector> d_rrsigs; + std::vector> d_nsec3params; ContentSigPair d_nsecs; map d_nsec3s; DNSName d_nsec3label;