]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
boost::replace_all > std::replace
authorRosen Penev <rosenp@gmail.com>
Fri, 13 Dec 2024 18:57:03 +0000 (10:57 -0800)
committerRosen Penev <rosenp@gmail.com>
Wed, 22 Jan 2025 00:16:56 +0000 (16:16 -0800)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
modules/geoipbackend/geoipinterface-dat.cc
pdns/dnsdistdist/dnsdist-actions.cc
pdns/dnsdistdist/dnsdist-carbon.cc
pdns/dnsdistdist/dnsdist-secpoll.cc
pdns/dnsdistdist/dnsdist-web.cc
pdns/dnsdistdist/doh.cc
pdns/lua-record.cc
pdns/misc.cc
pdns/recursordist/secpoll-recursor.cc
pdns/secpoll-auth.cc
pdns/test-misc_hh.cc

index f694eca883980bfadf5b21df93b0dac03f4305d7..db87a2057631a90680bce17329e0bb477b1fc6bc 100644 (file)
@@ -287,7 +287,7 @@ public:
         free(result);
         gl.netmask = tmp_gl.netmask;
         // reduce space to dash
-        ret = boost::replace_all_copy(ret, " ", "-");
+        std::replace(ret.begin(), ret.end(), ' ', '-');
         return true;
       }
     }
@@ -306,7 +306,7 @@ public:
         free(result);
         gl.netmask = tmp_gl.netmask;
         // reduce space to dash
-        ret = boost::replace_all_copy(ret, " ", "-");
+        std::replace(ret.begin(), ret.end(), ' ', '-');
         return true;
       }
     }
index ad19901f2a6caf27a33b04f57cc55cbf28139058..a56079915f38d5045d73b349841aeb20501fefba 100644 (file)
@@ -45,7 +45,7 @@ DNSAction::Action DNSAction::typeFromString(const std::string& str)
   };
 
   auto lower = boost::to_lower_copy(str);
-  boost::replace_all(lower, "-", "");
+  lower.erase(std::remove(lower.begin(), lower.end(), '-'), lower.end());
   auto mappingIt = s_mappings.find(lower);
   if (mappingIt != s_mappings.end()) {
     return mappingIt->second;
index 66ec734250e4c2d416a7a977c68e3bda4955cb7c..eee7a5df96e4196958435f5a9e8a3dcdbbdf4038 100644 (file)
@@ -78,7 +78,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
 
     for (const auto& state : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
       string serverName = state->getName().empty() ? state->d_config.remote.toStringWithPort() : state->getName();
-      boost::replace_all(serverName, ".", "_");
+      std::replace(serverName.begin(), serverName.end(), '.', '_');
       string base = namespace_name;
       base += ".";
       base += hostname;
@@ -123,7 +123,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
       }
 
       string frontName = front->local.toStringWithPort() + (front->udpFD >= 0 ? "_udp" : "_tcp");
-      boost::replace_all(frontName, ".", "_");
+      std::replace(frontName.begin(), frontName.end(), '.', '_');
       auto dupPair = frontendDuplicates.insert({frontName, 1});
       if (!dupPair.second) {
         frontName += "_" + std::to_string(dupPair.first->second);
@@ -180,7 +180,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
 
     for (const auto& entry : dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools) {
       string poolName = entry.first;
-      boost::replace_all(poolName, ".", "_");
+      std::replace(poolName.begin(), poolName.end(), '.', '_');
       if (poolName.empty()) {
         poolName = "_default_";
       }
@@ -228,10 +228,10 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
       const string base = "dnsdist." + hostname + ".main.doh.";
       for (const auto& doh : dnsdist::getDoHFrontends()) {
         string name = doh->d_tlsContext.d_addr.toStringWithPort();
-        boost::replace_all(name, ".", "_");
-        boost::replace_all(name, ":", "_");
-        boost::replace_all(name, "[", "_");
-        boost::replace_all(name, "]", "_");
+        std::replace(name.begin(), name.end(), '.', '_');
+        std::replace(name.begin(), name.end(), ':', '_');
+        std::replace(name.begin(), name.end(), '[', '_');
+        std::replace(name.begin(), name.end(), ']', '_');
 
         auto dupPair = dohFrontendDuplicates.insert({name, 1});
         if (!dupPair.second) {
@@ -274,7 +274,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
       auto records = dnsdist::QueryCount::g_queryCountRecords.write_lock();
       for (const auto& record : *records) {
         qname = record.first;
-        boost::replace_all(qname, ".", "_");
+        std::replace(qname.begin(), qname.end(), '.', '_');
         str << "dnsdist.querycount." << qname << ".queries " << record.second << " " << now << "\r\n";
       }
       records->clear();
index 5f6bb57333556d6316c85d79280ed05e73b76855..647b09fb83ae1f4b062c7e2d6a882761345d730b 100644 (file)
@@ -205,8 +205,8 @@ void doSecPoll(const std::string& suffix)
     queriedName += '.';
   }
 
-  boost::replace_all(queriedName, "+", "_");
-  boost::replace_all(queriedName, "~", "_");
+  std::replace(queriedName.begin(), queriedName.end(), '+', '_');
+  std::replace(queriedName.begin(), queriedName.end(), '~', '_');
 
   try {
     std::string status = getSecPollStatus(queriedName);
index 253c00d3bb2d2f6c84b81dabf7cdbf027010d4ae..f4c9431b64b55733ab5fa54b708bbe875164b7bd 100644 (file)
@@ -623,7 +623,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
       serverName = state->getName();
     }
 
-    boost::replace_all(serverName, ".", "_");
+    std::replace(serverName.begin(), serverName.end(), '.', '_');
 
     const std::string label = boost::str(boost::format(R"({server="%1%",address="%2%"})")
                                          % serverName % state->d_config.remote.toStringWithPort());
index 739684477b8277de8ac606ef936b8fa92000d899..eb95c1302ce5844bcd7970ca07cdf91d45b82f86 100644 (file)
@@ -1145,8 +1145,8 @@ static int doh_handler(h2o_handler_t *self, h2o_req_t *req)
       if (pos != string::npos) {
         // need to base64url decode this
         string sdns(path.substr(pos+5));
-        boost::replace_all(sdns,"-", "+");
-        boost::replace_all(sdns,"_", "/");
+        std::replace(sdns.begin(), sdns.end(), '-', '+');
+        std::replace(sdns.begin(), sdns.end(), '_', '/');
         // re-add padding that may have been missing
         switch (sdns.size() % 4) {
         case 2:
index 32b8bab5582c674c69654ac67b0211dc6639f20a..13b97f46b146724c5ac6644e9d3e0112e7dababd 100644 (file)
@@ -930,7 +930,7 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn
       vector<ComboAddress> candidates;
       // Getting something like 192-0-2-1.192-0-2-2.198-51-100-1.example.org
       for(auto l : s_lua_record_ctx->qname.getRawLabels()) {
-        boost::replace_all(l, "-", ".");
+        std::replace(l.begin(), l.end(), '-', '.');
         try {
           candidates.emplace_back(l);
         } catch (const PDNSException& e) {
@@ -1071,7 +1071,7 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn
       }
       else if(parts.size()==1) {
         if (parts[0].find('-') != std::string::npos) {
-          boost::replace_all(parts[0],"-",":");
+          std::replace(parts[0].begin(), parts[0].end(), '-', ':');
           ComboAddress ca(parts[0]);
           return ca.toString();
         } else {
@@ -1130,7 +1130,7 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn
         }
 
         string dashed=ip6.toString();
-        boost::replace_all(dashed, ":", "-");
+        std::replace(dashed.begin(), dashed.end(), ':', '-');
 
         for(int i=31; i>=0; --i)
           fmt % labels[i];
index 1cc6d5114b2c8069f7c003e6e4785eab40c8c24e..8f0a7bd45333be160b5e45f791c9b66860e350db 100644 (file)
@@ -568,7 +568,7 @@ std::string getCarbonHostName()
     throw std::runtime_error(stringerror());
   }
 
-  boost::replace_all(*hostname, ".", "_");
+  std::replace(hostname->begin(), hostname->end(), '.', '_');
   return *hostname;
 }
 
index b54ae7dc5c71ca74d40a80f979160196d268a47c..6c89a406a1dae777d40f933114f5fbfef368fe22 100644 (file)
@@ -49,8 +49,8 @@ void doSecPoll(time_t* last_secpoll, Logr::log_t log)
     qstring += '.';
   }
 
-  boost::replace_all(qstring, "+", "_");
-  boost::replace_all(qstring, "~", "_");
+  std::replace(qstring.begin(), qstring.end(), '+', '_');
+  std::replace(qstring.begin(), qstring.end(), '~', '_');
 
   vState state = vState::Indeterminate;
   DNSName query(qstring);
index 7cc132aada7a39d7b4f046d677d22002a46b5dc7..139f28acfd2fc93be2b3c9c046a4effa9c129140 100644 (file)
@@ -44,8 +44,8 @@ void doSecPoll(bool first)
   if(*query.rbegin()!='.')
     query+='.';
 
-  boost::replace_all(query, "+", "_");
-  boost::replace_all(query, "~", "_");
+  std::replace(query.begin(), query.end(), '+', '_');
+  std::replace(query.begin(), query.end(), '~', '_');
 
   int security_status = std::stoi(S.getValueStr("security-status"));
 
index bb903d6236050b126c35c21c30458f6eefbe5852..45e9e375f9649a450f82fef42380b22ce84d10b8 100644 (file)
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(test_getCarbonHostName)
 
   BOOST_CHECK_EQUAL(gethostname(buffer, sizeof buffer), 0);
   std::string my_hostname(buffer);
-  boost::replace_all(my_hostname, ".", "_");
+  std::replace(my_hostname.begin(), my_hostname.end(), '.', '_');
 
   std::string hostname = getCarbonHostName();
   // ensure it matches what we get