]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsname: Add a comment about what `DNSName::matches` accepts
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 Jul 2025 09:29:40 +0000 (11:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 Jul 2025 09:29:40 +0000 (11:29 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsname.hh
pdns/test-dnsname_cc.cc

index a8fcf47f882db857fc9137952fed4ec395e26941..5d62f38ea4234a9d19fef5ea103b9db3bff92b4a 100644 (file)
@@ -115,7 +115,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;
index dd415490536feb8500a37f2e4a62a0e08aade311..ad4f31522f4bbd5e09264ea4a9925e76d2f12e5e 100644 (file)
@@ -1042,7 +1042,7 @@ BOOST_AUTO_TEST_CASE(test_raw_data_comparison) {
     const std::string_view raw(reinterpret_cast<const char*>(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");