]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Current code doesn't care if dnssec is enabled or not; reorder struct Config
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 29 Sep 2021 14:36:42 +0000 (16:36 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Mon, 4 Oct 2021 10:46:07 +0000 (12:46 +0200)
pdns/recursordist/rec-zonetocache.cc
pdns/recursordist/rec-zonetocache.hh

index 9e4a4899beaef79c9a75d98abeccb14ec5503a60..053ddbcb567c103d81f839660e1fda2c9ad87f89 100644 (file)
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <algorithm>
 #include "rec-zonetocache.hh"
 
 #include "syncres.hh"
@@ -37,17 +38,10 @@ time_t RecZoneToCache::ZonesToCache(const std::vector<Config>& cfgs)
   // By default and max once per 24 hours
   time_t refresh = 24 * 3600;
 
-  struct timeval now;
-  gettimeofday(&now, nullptr);
-  SyncRes sr(now);
-  bool dnssec = g_dnssecmode != DNSSECMode::Off;
-  sr.setDoDNSSEC(dnssec);
-  sr.setDNSSECValidationRequested(g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate);
-
   for (const auto& config : cfgs) {
     const string msg = "zones-to-cache error while loading " + config.d_zone + ": ";
     try {
-      refresh = min(refresh, ZoneToCache(config, dnssec));
+      refresh = std::min(refresh, ZoneToCache(config));
     }
     catch (const PDNSException& e) {
       g_log << Logger::Error << msg << e.reason << endl;
@@ -60,7 +54,7 @@ time_t RecZoneToCache::ZonesToCache(const std::vector<Config>& cfgs)
     }
 
     // We do not want to refresh more than once per hour
-    refresh = std::max(refresh, 3600LL);
+    refresh = std::max(refresh, static_cast<time_t>(3600));
   }
 
   return refresh;
@@ -103,7 +97,7 @@ void ZoneData::parseDRForCache(DNSRecord& dr)
 {
   const auto key = make_pair(dr.d_name, dr.d_type);
 
-  d_refresh = min(d_refresh, static_cast<time_t>(dr.d_ttl));
+  d_refresh = std::min(d_refresh, static_cast<time_t>(dr.d_ttl));
   dr.d_ttl += d_now;
 
   switch (dr.d_type) {
@@ -202,7 +196,7 @@ static std::vector<std::string> getURL(const RecZoneToCache::Config& config)
   return lines;
 }
 
-time_t RecZoneToCache::ZoneToCache(const Config& config, bool dnssec)
+time_t RecZoneToCache::ZoneToCache(const Config& config)
 {
   if (config.d_sources.size() > 1) {
     // XXX Warning
index d95891e9557fe0bff08e38f233250ff5a486ca80..8d80913e565c08f0c1ef24752ae26ecc21633118 100644 (file)
@@ -34,13 +34,13 @@ public:
     std::string d_zone; // Zone name
     std::string d_method; // axfr, http, https, file
     vector<std::string> d_sources; // IPs or URLs
-    uint32_t d_timeout{20}; // timeout in seconds
     ComboAddress d_local; // local address
-    size_t d_maxReceivedBytes{0}; // Maximum size
     TSIGTriplet d_tt; // Authentication data
+    size_t d_maxReceivedBytes{0}; // Maximum size
+    uint32_t d_timeout{20}; // timeout in seconds
   };
   static time_t ZonesToCache(const std::vector<Config>&);
 
 private:
-  static time_t ZoneToCache(const Config& config, bool dnssec);
+  static time_t ZoneToCache(const Config& config);
 };