From 32122aab664b8d3385f9313458227a4fb16dcd1c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 23 May 2018 10:35:17 +0200 Subject: [PATCH] Allocate DNSRecord objects as smart pointers right away (cherry picked from commit 1339125af5afe6d6ecfe0a500c5fdc76d790459d) --- pdns/dnsparser.cc | 18 +++---------- pdns/dnsparser.hh | 5 ++-- pdns/dnsrecords.cc | 16 +++++------ pdns/dnsrecords.hh | 40 ++++++++++++++-------------- pdns/nsecrecords.cc | 24 ++++++++--------- pdns/rec-lua-conf.cc | 6 ++--- pdns/rec_channel_rec.cc | 2 +- pdns/recursordist/test-syncres_cc.cc | 4 +-- pdns/sillyrecords.cc | 8 +++--- pdns/speedtest.cc | 26 +++++++++--------- pdns/test-dnsrecordcontent.cc | 12 ++++----- pdns/test-signers.cc | 6 ++--- pdns/toysdig.cc | 2 +- pdns/ws-auth.cc | 2 +- 14 files changed, 79 insertions(+), 92 deletions(-) diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 29bbb4314..e88881113 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -131,7 +131,7 @@ std::shared_ptr DNSRecordContent::mastermake(const DNSRecord & return std::make_shared(dr, pr); } - return std::shared_ptr(i->second(dr, pr)); + return i->second(dr, pr); } std::shared_ptr DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass, @@ -142,21 +142,9 @@ std::shared_ptr DNSRecordContent::mastermake(uint16_t qtype, u return std::make_shared(content); } - return std::shared_ptr(i->second(content)); + return i->second(content); } -std::unique_ptr DNSRecordContent::makeunique(uint16_t qtype, uint16_t qclass, - const string& content) -{ - zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype)); - if(i==getZmakermap().end()) { - return std::unique_ptr(new UnknownRecordContent(content)); - } - - return std::unique_ptr(i->second(content)); -} - - std::shared_ptr DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t oc) { // For opcode UPDATE and where the DNSRecord is an answer record, we don't care about content, because this is // not used within the prerequisite section of RFC2136, so - we can simply use unknownrecordcontent. @@ -171,7 +159,7 @@ std::shared_ptr DNSRecordContent::mastermake(const DNSRecord & return std::make_shared(dr, pr); } - return std::shared_ptr(i->second(dr, pr)); + return i->second(dr, pr); } diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index 3cc710f43..33228bdac 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -195,7 +195,6 @@ public: static std::shared_ptr mastermake(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode); static std::shared_ptr mastermake(uint16_t qtype, uint16_t qclass, const string& zone); - static std::unique_ptr makeunique(uint16_t qtype, uint16_t qclass, const string& content); virtual std::string getZoneRepresentation(bool noDot=false) const = 0; virtual ~DNSRecordContent() {} @@ -227,8 +226,8 @@ public: void doRecordCheck(const struct DNSRecord&){} - typedef DNSRecordContent* makerfunc_t(const struct DNSRecord& dr, PacketReader& pr); - typedef DNSRecordContent* zmakerfunc_t(const string& str); + typedef std::shared_ptr makerfunc_t(const struct DNSRecord& dr, PacketReader& pr); + typedef std::shared_ptr zmakerfunc_t(const string& str); static void regist(uint16_t cl, uint16_t ty, makerfunc_t* f, zmakerfunc_t* z, const char* name) { diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 0eaeed74b..6dd699bb7 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -405,19 +405,19 @@ void EUI48RecordContent::report(void) { regist(1, QType::EUI48, &make, &make, "EUI48"); } -DNSRecordContent* EUI48RecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr EUI48RecordContent::make(const DNSRecord &dr, PacketReader& pr) { if(dr.d_clen!=6) throw MOADNSException("Wrong size for EUI48 record"); - EUI48RecordContent* ret=new EUI48RecordContent(); + auto ret=std::make_shared(); pr.copyRecord((uint8_t*) &ret->d_eui48, 6); return ret; } -DNSRecordContent* EUI48RecordContent::make(const string& zone) +std::shared_ptr EUI48RecordContent::make(const string& zone) { // try to parse - EUI48RecordContent *ret=new EUI48RecordContent(); + auto ret=std::make_shared(); // format is 6 hex bytes and dashes if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", ret->d_eui48, ret->d_eui48+1, ret->d_eui48+2, @@ -448,19 +448,19 @@ void EUI64RecordContent::report(void) { regist(1, QType::EUI64, &make, &make, "EUI64"); } -DNSRecordContent* EUI64RecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr EUI64RecordContent::make(const DNSRecord &dr, PacketReader& pr) { if(dr.d_clen!=8) throw MOADNSException("Wrong size for EUI64 record"); - EUI64RecordContent* ret=new EUI64RecordContent(); + auto ret=std::make_shared(); pr.copyRecord((uint8_t*) &ret->d_eui64, 8); return ret; } -DNSRecordContent* EUI64RecordContent::make(const string& zone) +std::shared_ptr EUI64RecordContent::make(const string& zone) { // try to parse - EUI64RecordContent *ret=new EUI64RecordContent(); + auto ret=std::make_shared(); // format is 8 hex bytes and dashes if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", ret->d_eui64, ret->d_eui64+1, ret->d_eui64+2, diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 52cb01975..66e950f95 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -38,8 +38,8 @@ RNAME##RecordContent(const string& zoneData); \ static void report(void); \ static void unreport(void); \ - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); \ - static DNSRecordContent* make(const string& zonedata); \ + 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; } \ @@ -550,8 +550,8 @@ public: {} NSECRecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone? - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& content); + 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; uint16_t getType() const override @@ -571,8 +571,8 @@ public: {} NSEC3RecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone? - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& content); + 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; @@ -600,8 +600,8 @@ public: {} NSEC3PARAMRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone? - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& content); + 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; @@ -625,8 +625,8 @@ public: {} LOCRecordContent(const string& content, const string& zone=""); - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& content); + 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; @@ -649,8 +649,8 @@ public: {} WKSRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone? - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& content); + 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; @@ -664,8 +664,8 @@ class EUI48RecordContent : public DNSRecordContent public: EUI48RecordContent() {}; static void report(void); - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone? + 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; uint16_t getType() const override { return QType::EUI48; } @@ -679,8 +679,8 @@ class EUI64RecordContent : public DNSRecordContent public: EUI64RecordContent() {}; static void report(void); - static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone? + 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; uint16_t getType() const override { return QType::EUI64; } @@ -727,9 +727,9 @@ class CAARecordContent : public DNSRecordContent { }; #define boilerplate(RNAME, RTYPE) \ -RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \ +std::shared_ptr RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \ { \ - return new RNAME##RecordContent(dr, pr); \ + return std::make_shared(dr, pr); \ } \ \ RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr) \ @@ -738,9 +738,9 @@ RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr xfrPacket(pr); \ } \ \ -RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const string& zonedata) \ +std::shared_ptr RNAME##RecordContent::make(const string& zonedata) \ { \ - return new RNAME##RecordContent(zonedata); \ + return std::make_shared(zonedata); \ } \ \ void RNAME##RecordContent::toPacket(DNSPacketWriter& pw) \ diff --git a/pdns/nsecrecords.cc b/pdns/nsecrecords.cc index 1e212ae02..20329cf1e 100644 --- a/pdns/nsecrecords.cc +++ b/pdns/nsecrecords.cc @@ -29,9 +29,9 @@ void NSECRecordContent::report(void) regist(1, 47, &make, &make, "NSEC"); } -DNSRecordContent* NSECRecordContent::make(const string& content) +std::shared_ptr NSECRecordContent::make(const string& content) { - return new NSECRecordContent(content); + return std::make_shared(content); } NSECRecordContent::NSECRecordContent(const string& content, const string& zone) @@ -81,9 +81,9 @@ void NSECRecordContent::toPacket(DNSPacketWriter& pw) pw.xfrBlob(tmp); } -NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr) { - NSECRecordContent* ret=new NSECRecordContent(); + auto ret=std::make_shared(); pr.xfrName(ret->d_next); string bitmap; pr.xfrBlob(bitmap); @@ -136,9 +136,9 @@ void NSEC3RecordContent::report(void) regist(1, 50, &make, &make, "NSEC3"); } -DNSRecordContent* NSEC3RecordContent::make(const string& content) +std::shared_ptr NSEC3RecordContent::make(const string& content) { - return new NSEC3RecordContent(content); + return std::make_shared(content); } NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone) @@ -203,9 +203,9 @@ void NSEC3RecordContent::toPacket(DNSPacketWriter& pw) } } -NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr) { - NSEC3RecordContent* ret=new NSEC3RecordContent(); + auto ret=std::make_shared(); pr.xfr8BitInt(ret->d_algorithm); pr.xfr8BitInt(ret->d_flags); pr.xfr16BitInt(ret->d_iterations); @@ -272,9 +272,9 @@ void NSEC3PARAMRecordContent::report(void) regist(254, 51, &make, &make, "NSEC3PARAM"); } -DNSRecordContent* NSEC3PARAMRecordContent::make(const string& content) +std::shared_ptr NSEC3PARAMRecordContent::make(const string& content) { - return new NSEC3PARAMRecordContent(content); + return std::make_shared(content); } NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) @@ -296,9 +296,9 @@ void NSEC3PARAMRecordContent::toPacket(DNSPacketWriter& pw) pw.xfrBlob(d_salt); } -NSEC3PARAMRecordContent::DNSRecordContent* NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr) { - NSEC3PARAMRecordContent* ret=new NSEC3PARAMRecordContent(); + auto ret=std::make_shared(); pr.xfr8BitInt(ret->d_algorithm); pr.xfr8BitInt(ret->d_flags); pr.xfr16BitInt(ret->d_iterations); diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index dfa539841..ab7c52195 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -35,7 +35,7 @@ LuaConfigItems::LuaConfigItems() { DNSName root("."); // don't use g_rootdnsname here, it might not exist yet for (const auto &dsRecord : rootDSs) { - auto ds=unique_ptr(dynamic_cast(DSRecordContent::make(dsRecord))); + auto ds=std::dynamic_pointer_cast(DSRecordContent::make(dsRecord)); dsAnchors[root].insert(*ds); } } @@ -361,7 +361,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de Lua.writeFunction("addTA", [&lci](const std::string& who, const std::string& what) { warnIfDNSSECDisabled("Warning: adding Trust Anchor for DNSSEC (addTA), but dnssec is set to 'off'!"); DNSName zone(who); - auto ds = unique_ptr(dynamic_cast(DSRecordContent::make(what))); + auto ds = std::dynamic_pointer_cast(DSRecordContent::make(what)); lci.dsAnchors[zone].insert(*ds); }); @@ -378,7 +378,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de warnIfDNSSECDisabled("Warning: adding Trust Anchor for DNSSEC (addDS), but dnssec is set to 'off'!"); g_log<(dynamic_cast(DSRecordContent::make(what))); + auto ds = std::dynamic_pointer_cast(DSRecordContent::make(what)); lci.dsAnchors[zone].insert(*ds); }); diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index bf8edd822..c70476389 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -573,7 +573,7 @@ string doAddTA(T begin, T end) try { g_log<(dynamic_cast(DSRecordContent::make(what))); + auto ds=std::dynamic_pointer_cast(DSRecordContent::make(what)); lci.dsAnchors[who].insert(*ds); }); broadcastAccFunction(boost::bind(pleaseWipeCache, who, true)); diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index a7280c026..c547ea3f5 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -92,7 +92,7 @@ void primeHints(void) LuaConfigItems::LuaConfigItems() { for (const auto &dsRecord : rootDSs) { - auto ds=unique_ptr(dynamic_cast(DSRecordContent::make(dsRecord))); + auto ds=std::dynamic_pointer_cast(DSRecordContent::make(dsRecord)); dsAnchors[g_rootdnsname].insert(*ds); } } @@ -154,7 +154,7 @@ static void init(bool debug=false) luaconfsCopy.dfe.clear(); luaconfsCopy.dsAnchors.clear(); for (const auto &dsRecord : rootDSs) { - auto ds=unique_ptr(dynamic_cast(DSRecordContent::make(dsRecord))); + auto ds=std::dynamic_pointer_cast(DSRecordContent::make(dsRecord)); luaconfsCopy.dsAnchors[g_rootdnsname].insert(*ds); } luaconfsCopy.negAnchors.clear(); diff --git a/pdns/sillyrecords.cc b/pdns/sillyrecords.cc index 289cdb18c..d4030ef26 100644 --- a/pdns/sillyrecords.cc +++ b/pdns/sillyrecords.cc @@ -159,9 +159,9 @@ void LOCRecordContent::report(void) regist(254, QType::LOC, &make, &make, "LOC"); } -DNSRecordContent* LOCRecordContent::make(const string& content) +std::shared_ptr LOCRecordContent::make(const string& content) { - return new LOCRecordContent(content); + return std::make_shared(content); } @@ -177,9 +177,9 @@ void LOCRecordContent::toPacket(DNSPacketWriter& pw) pw.xfr32BitInt(d_altitude); } -LOCRecordContent::DNSRecordContent* LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) +std::shared_ptr LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) { - LOCRecordContent* ret=new LOCRecordContent(); + auto ret=std::make_shared(); pr.xfr8BitInt(ret->d_version); pr.xfr8BitInt(ret->d_size); pr.xfr8BitInt(ret->d_horizpre); diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 6675260bb..d613f1126 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -229,24 +229,24 @@ vector makeBigReferral() for(char c='a'; c<= 'm';++c) { pw.startRecord(DNSName("com"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); gtld[0]=c; - auto drc = DNSRecordContent::makeunique(QType::NS, 1, gtld); + auto drc = DNSRecordContent::mastermake(QType::NS, 1, gtld); drc->toPacket(pw); } for(char c='a'; c<= 'k';++c) { gtld[0]=c; pw.startRecord(DNSName(gtld), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - auto drc = DNSRecordContent::makeunique(QType::A, 1, "1.2.3.4"); + auto drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); drc->toPacket(pw); } pw.startRecord(DNSName("a.gtld-servers.net"), QType::AAAA, 3600, 1, DNSResourceRecord::ADDITIONAL); - auto aaaarc = DNSRecordContent::makeunique(QType::AAAA, 1, "2001:503:a83e::2:30"); + auto aaaarc = DNSRecordContent::mastermake(QType::AAAA, 1, "2001:503:a83e::2:30"); aaaarc->toPacket(pw); pw.startRecord(DNSName("b.gtld-servers.net"), QType::AAAA, 3600, 1, DNSResourceRecord::ADDITIONAL); - aaaarc = DNSRecordContent::makeunique(QType::AAAA, 1, "2001:503:231d::2:30"); + aaaarc = DNSRecordContent::mastermake(QType::AAAA, 1, "2001:503:231d::2:30"); aaaarc->toPacket(pw); @@ -293,7 +293,7 @@ vector makeBigDNSPacketReferral() // shuffle(records); for(const auto& rec : records) { pw.startRecord(rec.qname, rec.qtype.getCode(), rec.ttl, 1, DNSResourceRecord::ADDITIONAL); - auto drc = DNSRecordContent::makeunique(rec.qtype.getCode(), 1, rec.content); + auto drc = DNSRecordContent::mastermake(rec.qtype.getCode(), 1, rec.content); drc->toPacket(pw); } @@ -312,7 +312,7 @@ struct MakeARecordTestMM void operator()() const { - auto drc = DNSRecordContent::makeunique(QType::A, 1, + auto drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); } }; @@ -385,7 +385,7 @@ struct GenericRecordTest DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), d_type); for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), d_type); - auto drc = DNSRecordContent::makeunique(d_type, 1, + auto drc = DNSRecordContent::mastermake(d_type, 1, d_content); drc->toPacket(pw); } @@ -412,7 +412,7 @@ struct AAAARecordTest DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::AAAA); for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), QType::AAAA); - auto drc = DNSRecordContent::makeunique(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441"); + auto drc = DNSRecordContent::mastermake(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441"); drc->toPacket(pw); } pw.commit(); @@ -436,7 +436,7 @@ struct SOARecordTest for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), QType::SOA); - auto drc = DNSRecordContent::makeunique(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400"); + auto drc = DNSRecordContent::mastermake(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400"); drc->toPacket(pw); } pw.commit(); @@ -457,20 +457,20 @@ vector makeTypicalReferral() DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::A); pw.startRecord(DNSName("ds9a.nl"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); - auto drc = DNSRecordContent::makeunique(QType::NS, 1, "ns1.ds9a.nl"); + auto drc = DNSRecordContent::mastermake(QType::NS, 1, "ns1.ds9a.nl"); drc->toPacket(pw); pw.startRecord(DNSName("ds9a.nl"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); - drc = DNSRecordContent::makeunique(QType::NS, 1, "ns2.ds9a.nl"); + drc = DNSRecordContent::mastermake(QType::NS, 1, "ns2.ds9a.nl"); drc->toPacket(pw); pw.startRecord(DNSName("ns1.ds9a.nl"), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - drc = DNSRecordContent::makeunique(QType::A, 1, "1.2.3.4"); + drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); drc->toPacket(pw); pw.startRecord(DNSName("ns2.ds9a.nl"), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - drc = DNSRecordContent::makeunique(QType::A, 1, "4.3.2.1"); + drc = DNSRecordContent::mastermake(QType::A, 1, "4.3.2.1"); drc->toPacket(pw); pw.commit(); diff --git a/pdns/test-dnsrecordcontent.cc b/pdns/test-dnsrecordcontent.cc index 9eb6829b3..1d99f1f6c 100644 --- a/pdns/test-dnsrecordcontent.cc +++ b/pdns/test-dnsrecordcontent.cc @@ -21,12 +21,12 @@ BOOST_AUTO_TEST_CASE(test_equality) { BOOST_CHECK(aaaa == aaaa1); - auto rec1=DNSRecordContent::makeunique(QType::A, 1, "192.168.0.1"); - auto rec2=DNSRecordContent::makeunique(QType::A, 1, "192.168.222.222"); - auto rec3=DNSRecordContent::makeunique(QType::AAAA, 1, "::1"); - auto recMX=DNSRecordContent::makeunique(QType::MX, 1, "25 smtp.powerdns.com"); - auto recMX2=DNSRecordContent::makeunique(QType::MX, 1, "26 smtp.powerdns.com"); - auto recMX3=DNSRecordContent::makeunique(QType::MX, 1, "26 SMTP.powerdns.com"); + auto rec1=DNSRecordContent::mastermake(QType::A, 1, "192.168.0.1"); + auto rec2=DNSRecordContent::mastermake(QType::A, 1, "192.168.222.222"); + auto rec3=DNSRecordContent::mastermake(QType::AAAA, 1, "::1"); + auto recMX=DNSRecordContent::mastermake(QType::MX, 1, "25 smtp.powerdns.com"); + auto recMX2=DNSRecordContent::mastermake(QType::MX, 1, "26 smtp.powerdns.com"); + auto recMX3=DNSRecordContent::mastermake(QType::MX, 1, "26 SMTP.powerdns.com"); BOOST_CHECK(!(*rec1==*rec2)); BOOST_CHECK(*rec1==*rec1); BOOST_CHECK(*rec3==*rec3); diff --git a/pdns/test-signers.cc b/pdns/test-signers.cc index 42d8bd063..c8fbbf8cb 100644 --- a/pdns/test-signers.cc +++ b/pdns/test-signers.cc @@ -126,11 +126,11 @@ static void checkRR(const signerParams& signer) rrc.d_signer = DNSName("example.net."); inception = 946684800; expire = 1893456000; - rrs.push_back(DNSRecordContent::makeunique(QType::A, QClass::IN, "192.0.2.1")); + rrs.push_back(DNSRecordContent::mastermake(QType::A, QClass::IN, "192.0.2.1")); } else { rrc.d_signer = qname; - rrs.push_back(DNSRecordContent::makeunique(QType::MX, QClass::IN, "10 mail.example.com.")); + rrs.push_back(DNSRecordContent::mastermake(QType::MX, QClass::IN, "10 mail.example.com.")); } rrc.d_originalttl = 3600; @@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE(test_ed448_signer) { reportBasicTypes(); - rrs.push_back(DNSRecordContent::makeunique(QType::MX, 1, "10 mail.example.com.")); + rrs.push_back(DNSRecordContent::mastermake(QType::MX, 1, "10 mail.example.com.")); RRSIGRecordContent rrc; rrc.d_originalttl = 3600; diff --git a/pdns/toysdig.cc b/pdns/toysdig.cc index 7012b42e1..f238f4e24 100644 --- a/pdns/toysdig.cc +++ b/pdns/toysdig.cc @@ -102,7 +102,7 @@ GlobalStateHolder g_luaconfs; LuaConfigItems::LuaConfigItems() { for (const auto &dsRecord : rootDSs) { - auto ds=unique_ptr(dynamic_cast(DSRecordContent::make(dsRecord))); + auto ds=std::dynamic_pointer_cast(DSRecordContent::make(dsRecord)); dsAnchors[g_rootdnsname].insert(*ds); } } diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 1df76b166..2a4083631 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -289,7 +289,7 @@ void AuthWebServer::indexfunction(HttpRequest* req, HttpResponse* resp) /** Helper to build a record content as needed. */ static inline string makeRecordContent(const QType& qtype, const string& content, bool noDot) { // noDot: for backend storage, pass true. for API users, pass false. - auto drc = DNSRecordContent::makeunique(qtype.getCode(), QClass::IN, content); + auto drc = DNSRecordContent::mastermake(qtype.getCode(), QClass::IN, content); return drc->getZoneRepresentation(noDot); } -- 2.40.0