]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Allocate DNSRecord objects as smart pointers right away
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 23 May 2018 08:35:17 +0000 (10:35 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 2 Nov 2018 15:54:47 +0000 (16:54 +0100)
(cherry picked from commit 1339125af5afe6d6ecfe0a500c5fdc76d790459d)

14 files changed:
pdns/dnsparser.cc
pdns/dnsparser.hh
pdns/dnsrecords.cc
pdns/dnsrecords.hh
pdns/nsecrecords.cc
pdns/rec-lua-conf.cc
pdns/rec_channel_rec.cc
pdns/recursordist/test-syncres_cc.cc
pdns/sillyrecords.cc
pdns/speedtest.cc
pdns/test-dnsrecordcontent.cc
pdns/test-signers.cc
pdns/toysdig.cc
pdns/ws-auth.cc

index 29bbb43142c8f36e6708cb70a0cb046b5ee68a54..e8888111365eafc1e3fecde1ea0906f430a73c9b 100644 (file)
@@ -131,7 +131,7 @@ std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(const DNSRecord &
     return std::make_shared<UnknownRecordContent>(dr, pr);
   }
 
-  return std::shared_ptr<DNSRecordContent>(i->second(dr, pr));
+  return i->second(dr, pr);
 }
 
 std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass,
@@ -142,21 +142,9 @@ std::shared_ptr<DNSRecordContent> DNSRecordContent::mastermake(uint16_t qtype, u
     return std::make_shared<UnknownRecordContent>(content);
   }
 
-  return std::shared_ptr<DNSRecordContent>(i->second(content));
+  return i->second(content);
 }
 
-std::unique_ptr<DNSRecordContent> 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<DNSRecordContent>(new UnknownRecordContent(content));
-  }
-
-  return std::unique_ptr<DNSRecordContent>(i->second(content));
-}
-
-
 std::shared_ptr<DNSRecordContent> 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> DNSRecordContent::mastermake(const DNSRecord &
     return std::make_shared<UnknownRecordContent>(dr, pr);
   }
 
-  return std::shared_ptr<DNSRecordContent>(i->second(dr, pr));
+  return i->second(dr, pr);
 }
 
 
index 3cc710f438c75aa9f287111db397f5dd7a125f38..33228bdac2344dd4a3f9b509449c3b7002c8ab15 100644 (file)
@@ -195,7 +195,6 @@ public:
   static std::shared_ptr<DNSRecordContent> mastermake(const DNSRecord &dr, PacketReader& pr);
   static std::shared_ptr<DNSRecordContent> mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode);
   static std::shared_ptr<DNSRecordContent> mastermake(uint16_t qtype, uint16_t qclass, const string& zone);
-  static std::unique_ptr<DNSRecordContent> 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<DNSRecordContent> makerfunc_t(const struct DNSRecord& dr, PacketReader& pr);
+  typedef std::shared_ptr<DNSRecordContent> zmakerfunc_t(const string& str);
 
   static void regist(uint16_t cl, uint16_t ty, makerfunc_t* f, zmakerfunc_t* z, const char* name)
   {
index 0eaeed74bae355cfffaa79aff323b9081fcb0aab..6dd699bb78fc1bc2d1629c8b5d9b79a459adb610 100644 (file)
@@ -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<DNSRecordContent> 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<EUI48RecordContent>();
     pr.copyRecord((uint8_t*) &ret->d_eui48, 6);
     return ret;
 }
-DNSRecordContent* EUI48RecordContent::make(const string& zone)
+std::shared_ptr<DNSRecordContent> EUI48RecordContent::make(const string& zone)
 {
     // try to parse
-    EUI48RecordContent *ret=new EUI48RecordContent();
+    auto ret=std::make_shared<EUI48RecordContent>();
     // 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<DNSRecordContent> 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<EUI64RecordContent>();
     pr.copyRecord((uint8_t*) &ret->d_eui64, 8);
     return ret;
 }
-DNSRecordContent* EUI64RecordContent::make(const string& zone)
+std::shared_ptr<DNSRecordContent> EUI64RecordContent::make(const string& zone)
 {
     // try to parse
-    EUI64RecordContent *ret=new EUI64RecordContent();
+    auto ret=std::make_shared<EUI64RecordContent>();
     // 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,
index 52cb01975ef1a11cb8b29d8115c8877cdd3ffda9..66e950f951bbd1b9d67555e534fe0ab930df219a 100644 (file)
@@ -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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);          \
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
+  static std::shared_ptr<DNSRecordContent> 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::DNSRecordContent> RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \
 {                                                                                                  \
-  return new RNAME##RecordContent(dr, pr);                                                         \
+  return std::make_shared<RNAME##RecordContent>(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::DNSRecordContent> RNAME##RecordContent::make(const string& zonedata)         \
 {                                                                                                  \
-  return new RNAME##RecordContent(zonedata);                                                       \
+  return std::make_shared<RNAME##RecordContent>(zonedata);                                         \
 }                                                                                                  \
                                                                                                    \
 void RNAME##RecordContent::toPacket(DNSPacketWriter& pw)                                           \
index 1e212ae02d4d6d1287c7f128400130dc24f540fe..20329cf1ea8fcfc6cde9cc90f16188485cc1fd06 100644 (file)
@@ -29,9 +29,9 @@ void NSECRecordContent::report(void)
   regist(1, 47, &make, &make, "NSEC");
 }
 
-DNSRecordContent* NSECRecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> NSECRecordContent::make(const string& content)
 {
-  return new NSECRecordContent(content);
+  return std::make_shared<NSECRecordContent>(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::DNSRecordContent> NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSECRecordContent* ret=new NSECRecordContent();
+  auto ret=std::make_shared<NSECRecordContent>();
   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<DNSRecordContent> NSEC3RecordContent::make(const string& content)
 {
-  return new NSEC3RecordContent(content);
+  return std::make_shared<NSEC3RecordContent>(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::DNSRecordContent> NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSEC3RecordContent* ret=new NSEC3RecordContent();
+  auto ret=std::make_shared<NSEC3RecordContent>();
   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<DNSRecordContent> NSEC3PARAMRecordContent::make(const string& content)
 {
-  return new NSEC3PARAMRecordContent(content);
+  return std::make_shared<NSEC3PARAMRecordContent>(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::DNSRecordContent> NSEC3PARAMRecordContent::make(const DNSRecord &dr, PacketReader& pr)
 {
-  NSEC3PARAMRecordContent* ret=new NSEC3PARAMRecordContent();
+  auto ret=std::make_shared<NSEC3PARAMRecordContent>();
   pr.xfr8BitInt(ret->d_algorithm); 
         pr.xfr8BitInt(ret->d_flags); 
         pr.xfr16BitInt(ret->d_iterations); 
index dfa539841e2dbc1df3911a06f33d6f4b7e8c3286..ab7c5219550128855752e1a9d6829e0d16fa09ea 100644 (file)
@@ -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<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
+    auto ds=std::dynamic_pointer_cast<DSRecordContent>(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<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(what)));
+      auto ds = std::dynamic_pointer_cast<DSRecordContent>(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<<Logger::Warning<<"addDS is deprecated and will be removed in the future, switch to addTA"<<endl;
       DNSName zone(who);
-      auto ds = unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(what)));
+      auto ds = std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(what));
       lci.dsAnchors[zone].insert(*ds);
   });
 
index bf8edd82202d0459d6e4900d8c7997eef3c9c1f5..c70476389a95de4c80f90daec6209bd33a417c8c 100644 (file)
@@ -573,7 +573,7 @@ string doAddTA(T begin, T end)
   try {
     g_log<<Logger::Warning<<"Adding Trust Anchor for "<<who<<" with data '"<<what<<"', requested via control channel";
     g_luaconfs.modify([who, what](LuaConfigItems& lci) {
-      auto ds = unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(what)));
+      auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(what));
       lci.dsAnchors[who].insert(*ds);
       });
     broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, who, true));
index a7280c026783a681cc9ca4c55575796bccde1074..c547ea3f58f25447e97431afb0e0028662c6724d 100644 (file)
@@ -92,7 +92,7 @@ void primeHints(void)
 LuaConfigItems::LuaConfigItems()
 {
   for (const auto &dsRecord : rootDSs) {
-    auto ds=unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
+    auto ds=std::dynamic_pointer_cast<DSRecordContent>(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<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
+    auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(dsRecord));
     luaconfsCopy.dsAnchors[g_rootdnsname].insert(*ds);
   }
   luaconfsCopy.negAnchors.clear();
index 289cdb18cb63feba7815964d6ec98a0c0dcc22a7..d4030ef26559dce0679e662e63a3f06a5d4c4fe9 100644 (file)
@@ -159,9 +159,9 @@ void LOCRecordContent::report(void)
   regist(254, QType::LOC, &make, &make, "LOC");
 }
 
-DNSRecordContent* LOCRecordContent::make(const string& content)
+std::shared_ptr<DNSRecordContent> LOCRecordContent::make(const string& content)
 {
-  return new LOCRecordContent(content);
+  return std::make_shared<LOCRecordContent>(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::DNSRecordContent> LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
 {
-  LOCRecordContent* ret=new LOCRecordContent();
+  auto ret=std::make_shared<LOCRecordContent>();
   pr.xfr8BitInt(ret->d_version);
   pr.xfr8BitInt(ret->d_size);
   pr.xfr8BitInt(ret->d_horizpre);
index 6675260bb9275e63065c1f3241713aec70baa7b0..d613f1126409018814b37310bf58fa2154f4b2ee 100644 (file)
@@ -229,24 +229,24 @@ vector<uint8_t> 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<uint8_t> 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<uint8_t> 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();
index 9eb6829b3cae5f68079ed9836f782fe499f33073..1d99f1f6c519f42e324c3ab9c5da1324be45932b 100644 (file)
@@ -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);
index 42d8bd063347af352b439df28cdc19b52b6bdc95..c8fbbf8cb6699552af649d8aa49f3a6dcc2f8ba9 100644 (file)
@@ -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;
index 7012b42e127d7561cf8975a38019561f68692af5..f238f4e24d3d490e591ca3b3bbc02b9ca10922c7 100644 (file)
@@ -102,7 +102,7 @@ GlobalStateHolder<LuaConfigItems> g_luaconfs;
 LuaConfigItems::LuaConfigItems()
 {
   for (const auto &dsRecord : rootDSs) {
-    auto ds=unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
+    auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(dsRecord));
     dsAnchors[g_rootdnsname].insert(*ds);
   }
 }
index 1df76b16689b0d6872a466aca8ac6361c2623a1f..2a4083631a2841a16d1e803c17e3d59b7789f07c 100644 (file)
@@ -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);
 }