]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Switch to the pdns_string_view alias to prevent collisions
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 21 Sep 2020 08:49:16 +0000 (10:49 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 21 Sep 2020 08:49:16 +0000 (10:49 +0200)
pdns/dnsdist-cache.cc
pdns/dnsdistdist/doh.cc
pdns/packetcache.hh
pdns/views.hh

index fa38fbb9dd5efbe4bb7e170e97aaa1920d3d7223..79f12234f2222b48eb1b167c155a4c7f576fe303 100644 (file)
@@ -429,7 +429,7 @@ uint32_t DNSDistPacketCache::getKey(const DNSName::string_t& qname, uint16_t con
   if (packetLen > ((sizeof(dnsheader) + consumed))) {
     if (!d_cookieHashing) {
       /* skip EDNS Cookie options if any */
-      result = PacketCache::hashAfterQname(string_view(reinterpret_cast<const char*>(packet), packetLen), result, sizeof(dnsheader) + consumed, false);
+      result = PacketCache::hashAfterQname(pdns_string_view(reinterpret_cast<const char*>(packet), packetLen), result, sizeof(dnsheader) + consumed, false);
     }
     else {
       result = burtle(packet + sizeof(dnsheader) + consumed, packetLen - (sizeof(dnsheader) + consumed), result);
index 24e17b000c345feb45853a45c1991e2edb8535ab..080c95e3b8174f07197f8225e7ac4ba1ea7d8bc0 100644 (file)
@@ -710,15 +710,15 @@ static void doh_dispatch_query(DOHServerConfig* dsc, h2o_handler_t* self, h2o_re
 }
 
 /* can only be called from the main DoH thread */
-static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, string_view& value)
+static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, pdns_string_view& value)
 {
   bool found = false;
   /* early versions of boost::string_ref didn't have the ability to compare to string */
-  string_view headerNameView(headerName);
+  pdns_string_view headerNameView(headerName);
 
   for (size_t i = 0; i < req->headers.size; ++i) {
-    if (string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) {
-      value = string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len);
+    if (pdns_string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) {
+      value = pdns_string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len);
       /* don't stop there, we might have more than one header with the same name, and we want the last one */
       found = true;
     }
@@ -731,12 +731,12 @@ static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerNa
 static void processForwardedForHeader(const h2o_req_t* req, ComboAddress& remote)
 {
   static const std::string headerName = "x-forwarded-for";
-  string_view value;
+  pdns_string_view value;
 
   if (getHTTPHeaderValue(req, headerName, value)) {
     try {
       auto pos = value.rfind(',');
-      if (pos != string_view::npos) {
+      if (pos != pdns_string_view::npos) {
         ++pos;
         for (; pos < value.size() && value[pos] == ' '; ++pos)
         {
index a8cf718888eb9953c72cfc41e12d90d995de547c..da3b62190d34af9e2ab0baa0ea5fab9bf314371d 100644 (file)
@@ -34,7 +34,7 @@ public:
      - EDNS Cookie options, if any ;
      - EDNS Client Subnet options, if any and skipECS is true.
   */
-  static uint32_t hashAfterQname(const string_view& packet, uint32_t currentHash, size_t pos, bool skipECS)
+  static uint32_t hashAfterQname(const pdns_string_view& packet, uint32_t currentHash, size_t pos, bool skipECS)
   {
     const size_t packetSize = packet.size();
     assert(packetSize >= sizeof(dnsheader));
index 21fa8bb2ce8450431d9ef16765111d4c9e434df9..d931c094368497ab55d2d775c83f33bc06f64e80 100644 (file)
 #pragma once
 
 #ifdef __cpp_lib_string_view
-using std::string_view;
+using pdns_string_view = std::string_view;
 #else
 #include <boost/version.hpp>
 #if BOOST_VERSION >= 106400
 // string_view already exists in 1.61.0 but string_view::at() is not usable with modern compilers, see:
 // https://github.com/boostorg/utility/pull/26
 #include <boost/utility/string_view.hpp>
-using boost::string_view;
+using pdns_string_view = boost::string_view;
 #elif BOOST_VERSION >= 105300
 #include <boost/utility/string_ref.hpp>
-using string_view = boost::string_ref;
+using pdns_string_view = boost::string_ref;
 #else
-using string_view = std::string;
+using pdns_string_view = std::string;
 #endif
 #endif