]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Remove a few wire-related interfaces from ZoneName.
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 16 Apr 2025 08:40:34 +0000 (10:40 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Wed, 23 Apr 2025 14:42:19 +0000 (16:42 +0200)
This should prevent accidental use, by requiring an explicit conversion to
DNSName and thinking about what we are doing here.

modules/tinydnsbackend/tinydnsbackend.cc
pdns/dnsname.hh
pdns/pdnsutil.cc
pdns/ueberbackend.cc

index 0f5b714da3e035ea632bfe4a3207dbe3584924eb..ec9664e4a146da7bfe1f5615eeaf272ef5b6235d 100644 (file)
@@ -244,7 +244,7 @@ bool TinyDNSBackend::list(const ZoneName& target, int /* domain_id */, bool /* i
 {
   d_isAxfr = true;
   d_isGetDomains = false;
-  string key = target.toDNSStringLC();
+  string key = target.operator const DNSName&().toDNSStringLC();
   try {
     d_cdbReader = std::make_unique<CDB>(getArg("dbfile"));
   }
index d6ec4054db29fef5bc8d78a9c3505219cac811ea..74a7392376d82b8c7cd0d4894f3ae19a936aed27 100644 (file)
@@ -356,16 +356,8 @@ public:
   std::string toLogString() const { return d_name.toLogString(); }
   std::string toStringNoDot() const { return d_name.toStringNoDot(); }
   std::string toStringRootDot() const { return d_name.toStringRootDot(); }
-  std::string toDNSString() const { return d_name.toDNSString(); }
-  std::string toDNSStringLC() const { return d_name.toDNSStringLC(); }
 
   bool chopOff() { return d_name.chopOff(); }
-  ZoneName makeRelative(const ZoneName& zone) const
-  {
-    ZoneName ret(*this);
-    ret.d_name.makeUsRelative(zone.d_name);
-    return ret;
-  }
   ZoneName makeLowerCase() const
   {
     ZoneName ret(*this);
@@ -373,12 +365,7 @@ public:
     return ret;
   }
   void makeUsLowerCase() { d_name.makeUsLowerCase(); }
-  void makeUsRelative(const ZoneName& zone) { d_name.makeUsRelative(zone.d_name); }
-  bool isWildcard() const { return d_name.isWildcard(); }
-  bool isHostname() const { return d_name.isHostname(); }
-  size_t wirelength() const { return d_name.wirelength(); }
   bool empty() const { return d_name.empty(); }
-  bool isRoot() const { return d_name.isRoot(); }
   void clear() { d_name.clear(); }
   void trimToLabels(unsigned int trim) { d_name.trimToLabels(trim); }
   size_t hash(size_t init=0) const { return d_name.hash(init); }
@@ -387,14 +374,6 @@ public:
 
   bool canonCompare(const ZoneName& rhs) const { return d_name.canonCompare(rhs.d_name); }
 
-  typedef boost::container::string string_t;
-
-  const string_t& getStorage() const { return d_name.getStorage(); }
-
-  [[nodiscard]] size_t sizeEstimate() const { return d_name.sizeEstimate(); }
-
-  bool has8bitBytes() const { return d_name.has8bitBytes(); }
-
   // Conversion from ZoneName to DNSName
   explicit operator const DNSName&() const { return d_name; }
   explicit operator DNSName&() { return d_name; }
index 86b4325f064d646caf2f98fc439a5179daee9aee..467403e7c3ea30a6ac888c09f84b99af7b360c36 100644 (file)
@@ -345,9 +345,10 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const ZoneName& zone, co
   bool validKeys=dk.checkKeys(zone, checkKeyErrors);
 
   if (haveNSEC3) {
-    if(isSecure && zone.wirelength() > 222) {
+    auto wirelength = zone.operator const DNSName&().wirelength();
+    if(isSecure && wirelength > 222) {
       numerrors++;
-      cout<<"[Error] zone '" << zone << "' has NSEC3 semantics but is too long to have the hash prepended. Zone name is " << zone.wirelength() << " bytes long, whereas the maximum is 222 bytes." << endl;
+      cout<<"[Error] zone '" << zone << "' has NSEC3 semantics but is too long to have the hash prepended. Zone name is " << wirelength << " bytes long, whereas the maximum is 222 bytes." << endl;
     }
 
     vector<DNSBackend::KeyData> dbkeyset;
@@ -3496,8 +3497,8 @@ static int setNsec3(vector<string>& cmds, const std::string_view synopsis)
 
   DNSSECKeeper dk; //NOLINT(readability-identifier-length)
   ZoneName zone(cmds.at(1));
-  if (zone.wirelength() > 222) {
-    cerr<<"Cannot enable NSEC3 for " << zone << " as it is too long (" << zone.wirelength() << " bytes, maximum is 222 bytes)"<<endl;
+  if (auto wirelength = zone.operator const DNSName&().wirelength(); wirelength > 222) {
+    cerr<<"Cannot enable NSEC3 for " << zone << " as it is too long (" << wirelength << " bytes, maximum is 222 bytes)"<<endl;
     return 1;
   }
   if(ns3pr.d_algorithm != 1) {
index c180fd6092d7d2b56069efe6ca8680294193d0c4..0ea058798019faf508efdfdf74fac45888d8e54d 100644 (file)
@@ -398,12 +398,13 @@ static std::vector<std::unique_ptr<DNSBackend>>::iterator findBestMatchingBacken
 
     DLOG(g_log << Logger::Error << "backend: " << backend - backends.begin() << ", qname: " << shorter << endl);
 
-    if (bestMatch->first < shorter.wirelength()) {
+    auto wirelength = shorter.operator const DNSName&().wirelength();
+    if (bestMatch->first < wirelength) {
       DLOG(g_log << Logger::Error << "skipped, we already found a shorter best match in this backend: " << bestMatch->second.qname << endl);
       continue;
     }
 
-    if (bestMatch->first == shorter.wirelength()) {
+    if (bestMatch->first == wirelength) {
       DLOG(g_log << Logger::Error << "use shorter best match: " << bestMatch->second.qname << endl);
       *soaData = bestMatch->second;
       break;
@@ -455,7 +456,7 @@ bool UeberBackend::getAuth(const ZoneName& target, const QType& qtype, SOAData*
 
   bool found = false;
   ZoneName shorter(target);
-  vector<pair<size_t, SOAData>> bestMatches(backends.size(), pair(target.wirelength() + 1, SOAData()));
+  vector<pair<size_t, SOAData>> bestMatches(backends.size(), pair(target.operator const DNSName&().wirelength() + 1, SOAData()));
 
   bool first = true;
   while (first || shorter.chopOff()) {