From: Miod Vallat Date: Wed, 16 Apr 2025 08:40:34 +0000 (+0200) Subject: Remove a few wire-related interfaces from ZoneName. X-Git-Tag: dnsdist-2.0.0-alpha2~63^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e17f69f00cc06ac67f9399c77aff8d6798d0d2d;p=thirdparty%2Fpdns.git Remove a few wire-related interfaces from ZoneName. This should prevent accidental use, by requiring an explicit conversion to DNSName and thinking about what we are doing here. --- diff --git a/modules/tinydnsbackend/tinydnsbackend.cc b/modules/tinydnsbackend/tinydnsbackend.cc index 0f5b714da3..ec9664e4a1 100644 --- a/modules/tinydnsbackend/tinydnsbackend.cc +++ b/modules/tinydnsbackend/tinydnsbackend.cc @@ -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(getArg("dbfile")); } diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index d6ec4054db..74a7392376 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -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; } diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 86b4325f06..467403e7c3 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -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 dbkeyset; @@ -3496,8 +3497,8 @@ static int setNsec3(vector& 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)"< 222) { + cerr<<"Cannot enable NSEC3 for " << zone << " as it is too long (" << wirelength << " bytes, maximum is 222 bytes)"<>::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> bestMatches(backends.size(), pair(target.wirelength() + 1, SOAData())); + vector> bestMatches(backends.size(), pair(target.operator const DNSName&().wirelength() + 1, SOAData())); bool first = true; while (first || shorter.chopOff()) {