From: Remi Gacogne Date: Mon, 28 Jul 2025 09:29:40 +0000 (+0200) Subject: dnsname: Add a comment about what `DNSName::matches` accepts X-Git-Tag: dnsdist-2.0.1~15^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e23d9328bf37e773fd838674ce1e79f03b5565d;p=thirdparty%2Fpdns.git dnsname: Add a comment about what `DNSName::matches` accepts Signed-off-by: Remi Gacogne (cherry picked from commit 7394dd09afce13c1cd287c2b63f8d129e8be22af) Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 8d7a9571e..b09a004b5 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -112,7 +112,8 @@ public: bool isPartOf(const DNSName& rhs) const; //!< Are we part of the rhs name? Note that name.isPartOf(name). inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty bool operator!=(const DNSName& other) const { return !(*this == other); } - bool matches(const std::string_view& wire_uncompressed) const; // DNS-native (case insensitive) comparison against raw data in wire format + // !< DNS-native (case insensitive) comparison against raw data in wire format. The view has to start with the DNS name, but does not have to contain only a DNS name. For example passing a view of a DNS packet starting just after the DNS header is OK. + bool matches(const std::string_view& wire_uncompressed) const; std::string toString(const std::string& separator=".", const bool trailing=true) const; //!< Our human-friendly, escaped, representation void toString(std::string& output, const std::string& separator=".", const bool trailing=true) const; diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index 63207ad66..cf24bacd7 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -1042,7 +1042,7 @@ BOOST_AUTO_TEST_CASE(test_raw_data_comparison) { const std::string_view raw(reinterpret_cast(query.data()) + sizeof(dnsheader), query.size() - sizeof(dnsheader)); BOOST_CHECK(aroot.matches(raw)); - DNSName differentCase("A.RooT-Servers.NET"); + const DNSName differentCase("A.RooT-Servers.NET"); BOOST_CHECK(differentCase.matches(raw)); const DNSName broot("b.root-servers.net");