From: Otto Moerbeek Date: Wed, 17 Dec 2025 12:31:02 +0000 (+0100) Subject: wip X-Git-Tag: rec-5.4.0-beta1~56^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db8e58d2e78b364fd7e16cafda5caebaf886d350;p=thirdparty%2Fpdns.git wip Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/aggressive_nsec.cc b/pdns/recursordist/aggressive_nsec.cc index f1370d15e8..b89b9d7232 100644 --- a/pdns/recursordist/aggressive_nsec.cc +++ b/pdns/recursordist/aggressive_nsec.cc @@ -503,7 +503,7 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& std::vector wcSet; MemRecursorCache::SigRecs wcSignatures = MemRecursorCache::s_emptySigRecs; - if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), std::nullopt, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { + if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl); return false; } @@ -527,7 +527,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& std::vector wcSet; MemRecursorCache::SigRecs wcSignatures = MemRecursorCache::s_emptySigRecs; - if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), std::nullopt, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { + if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl); return false; } @@ -780,7 +780,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr& ret, int& res, const ComboAddress& who, const std::optional& routingTag, bool doDNSSEC, pdns::validation::ValidationContext& validationContext, const OptLog& log) +bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& res, const ComboAddress& who, const boost::optional& routingTag, bool doDNSSEC, pdns::validation::ValidationContext& validationContext, const OptLog& log) { std::shared_ptr> zoneEntry; if (type == QType::DS) { diff --git a/pdns/recursordist/aggressive_nsec.hh b/pdns/recursordist/aggressive_nsec.hh index 2c84f5e17c..faee812726 100644 --- a/pdns/recursordist/aggressive_nsec.hh +++ b/pdns/recursordist/aggressive_nsec.hh @@ -63,7 +63,7 @@ public: } void insertNSEC(const DNSName& zone, const DNSName& owner, const DNSRecord& record, const std::vector>& signatures, bool nsec3, const DNSName& qname = g_rootdnsname, QType qtype = QType::ENT); - bool getDenial(time_t, const DNSName& name, const QType& type, std::vector& ret, int& res, const ComboAddress& who, const std::optional& routingTag, bool doDNSSEC, pdns::validation::ValidationContext& validationContext, const OptLog& log = std::nullopt); + bool getDenial(time_t, const DNSName& name, const QType& type, std::vector& ret, int& res, const ComboAddress& who, const boost::optional& routingTag, bool doDNSSEC, pdns::validation::ValidationContext& validationContext, const OptLog& log = std::nullopt); void removeZoneInfo(const DNSName& zone, bool subzones); diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 205ccb9210..b0f2757d3a 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -82,7 +82,7 @@ bool g_reusePort{false}; bool g_gettagNeedsEDNSOptions{false}; bool g_useKernelTimestamp; std::atomic g_maxCacheEntries, g_maxPacketCacheEntries; -boost::container::flat_set g_avoidUdpSourcePorts; +std::vector g_avoidUdpSourcePorts; uint16_t g_minUdpSourcePort; uint16_t g_maxUdpSourcePort; double g_balancingFactor; @@ -176,7 +176,7 @@ int UDPClientSocks::makeClientSocket(int family, const std::optional::max() + 1); std::vector parts{}; stringtok(parts, ::arg()["udp-source-port-avoid"], ", "); for (const auto& part : parts) { @@ -1960,7 +1961,7 @@ static int initPorts(Logr::log_t log) log->info(Logr::Error, "Unable to launch, udp-source-port-avoid contains an invalid port number", "port", Logging::Loggable(part)); return 99; // this isn't going to fix itself either } - g_avoidUdpSourcePorts.insert(port); + g_avoidUdpSourcePorts[port] = true; } return 0; } diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index 083d3702ef..abbacf3300 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -45,8 +45,6 @@ #include "nod.hh" #endif /* NOD_ENABLED */ -#include - extern std::shared_ptr g_slogtcpin; extern std::shared_ptr g_slogudpin; @@ -286,7 +284,7 @@ extern thread_local FrameStreamServersInfo t_frameStreamServersInfo; extern thread_local FrameStreamServersInfo t_nodFrameStreamServersInfo; #endif /* HAVE_FSTRM */ -extern boost::container::flat_set g_avoidUdpSourcePorts; +extern std::vector g_avoidUdpSourcePorts; /* without reuseport, all listeners share the same sockets */ typedef vector>> deferredAdd_t; diff --git a/pdns/recursordist/recursor_cache.cc b/pdns/recursordist/recursor_cache.cc index da217a66d4..9ba58c13bc 100644 --- a/pdns/recursordist/recursor_cache.cc +++ b/pdns/recursordist/recursor_cache.cc @@ -328,7 +328,7 @@ MemRecursorCache::cache_t::const_iterator MemRecursorCache::getEntryUsingECSInde /* we have nothing more specific for you */ break; } - auto key = std::tuple(qname, qtype, std::nullopt, best); + auto key = std::tuple(qname, qtype, boost::none, best); auto entry = map.d_map.find(key); if (entry == map.d_map.end()) { /* ecsIndex is not up-to-date */ @@ -360,7 +360,7 @@ MemRecursorCache::cache_t::const_iterator MemRecursorCache::getEntryUsingECSInde } /* we have nothing specific, let's see if we have a generic one */ - auto key = std::tuple(qname, qtype, std::nullopt, Netmask()); + auto key = std::tuple(qname, qtype, boost::none, Netmask()); auto entry = map.d_map.find(key); if (entry != map.d_map.end()) { handleServeStaleBookkeeping(now, serveStale, entry); @@ -541,7 +541,7 @@ time_t MemRecursorCache::get(time_t now, const DNSName& qname, const QType qtype } } // Try (again) without tag - auto entries = getEntries(*lockedShard, qname, qtype, std::nullopt); + auto entries = getEntries(*lockedShard, qname, qtype, boost::none); if (entries.first != entries.second) { OrderedTagIterator_t firstIndexIterator; @@ -662,7 +662,7 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qty // We only store with a tag if we have an ednsmask and the tag is available // We only store an ednsmask if we do not have a tag and we do have a mask. - auto key = std::tuple(qname, qtype.getCode(), ednsmask ? routingTag : std::nullopt, (ednsmask && !routingTag) ? *ednsmask : Netmask()); + auto key = std::tuple(qname, qtype.getCode(), ednsmask ? routingTag : boost::none, (ednsmask && !routingTag) ? *ednsmask : Netmask()); bool isNew = false; cache_t::iterator stored = lockedShard->d_map.find(key); if (stored == lockedShard->d_map.end()) { @@ -1151,7 +1151,7 @@ bool MemRecursorCache::putRecordSet(T& message) { AuthRecsVec authRecs; SigRecsVec sigRecs; - CacheEntry cacheEntry{{g_rootdnsname, QType::A, std::nullopt, Netmask()}, false}; + CacheEntry cacheEntry{{g_rootdnsname, QType::A, boost::none, Netmask()}, false}; while (message.next()) { switch (message.tag()) { case PBCacheEntry::repeated_bytes_record: { diff --git a/pdns/recursordist/recursor_cache.hh b/pdns/recursordist/recursor_cache.hh index cb833ff90d..5d64ce4ffc 100644 --- a/pdns/recursordist/recursor_cache.hh +++ b/pdns/recursordist/recursor_cache.hh @@ -65,7 +65,7 @@ public: size_t getRecordSets(size_t perShard, size_t maxSize, std::string& ret); size_t putRecordSets(const std::string& pbuf); - using OptTag = std::optional; + using OptTag = boost::optional; using Flags = uint8_t; static constexpr Flags None = 0; @@ -102,9 +102,9 @@ public: bool d_tcp{false}; }; - [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = std::nullopt, SigRecs* signatures = nullptr, AuthRecs* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, Extra* extra = nullptr); + [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = boost::none, SigRecs* signatures = nullptr, AuthRecs* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, Extra* extra = nullptr); - void replace(time_t, const DNSName& qname, QType qtype, const vector& content, const SigRecsVec& signatures, const AuthRecsVec& authorityRecs, bool auth, const DNSName& authZone, const std::optional& ednsmask = std::nullopt, const OptTag& routingTag = std::nullopt, vState state = vState::Indeterminate, const std::optional& extra = std::nullopt, bool refresh = false, time_t ttl_time = time(nullptr)); + void replace(time_t, const DNSName& qname, QType qtype, const vector& content, const SigRecsVec& signatures, const AuthRecsVec& authorityRecs, bool auth, const DNSName& authZone, const std::optional& ednsmask = std::nullopt, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, const std::optional& extra = std::nullopt, bool refresh = false, time_t ttl_time = time(nullptr)); void doPrune(time_t now, size_t keep); uint64_t doDump(int fileDesc, size_t maxCacheEntries); diff --git a/pdns/recursordist/reczones-helpers.cc b/pdns/recursordist/reczones-helpers.cc index 68e4ad3dc9..0e9cf67fdf 100644 --- a/pdns/recursordist/reczones-helpers.cc +++ b/pdns/recursordist/reczones-helpers.cc @@ -41,7 +41,7 @@ static void putIntoCache(time_t now, QType qtype, vState state, const ComboAddre // Put non-default root hints into cache as authoritative. As argued below in // putDefaultHintsIntoCache, this is actually wrong, but people might depend on it by having // root-hints that refer to servers that aren't actually capable or willing to serve root data. - g_recCache->replace(now, name, qtype, aset, {}, {}, true, g_rootdnsname, std::nullopt, std::nullopt, state, MemRecursorCache::Extra{from, false}); + g_recCache->replace(now, name, qtype, aset, {}, {}, true, g_rootdnsname, std::nullopt, boost::none, state, MemRecursorCache::Extra{from, false}); } } @@ -158,11 +158,11 @@ void putDefaultHintsIntoCache(time_t now, std::vector& nsvec) * auth and will expire at the same time. A re-prime is then triggered, as before, when the * records were inserted with the auth bit set and the TTD comes. */ - g_recCache->replace(now, DNSName(templ), QType::A, {arr}, {}, {}, false, g_rootdnsname, std::nullopt, std::nullopt, vState::Insecure, MemRecursorCache::Extra{from, false}); + g_recCache->replace(now, DNSName(templ), QType::A, {arr}, {}, {}, false, g_rootdnsname, std::nullopt, boost::none, vState::Insecure, MemRecursorCache::Extra{from, false}); } if (!rootIps6.at(letter).empty()) { aaaarr.setContent(std::make_shared(ComboAddress(rootIps6.at(letter)))); - g_recCache->replace(now, DNSName(templ), QType::AAAA, {aaaarr}, {}, {}, false, g_rootdnsname, std::nullopt, std::nullopt, vState::Insecure, MemRecursorCache::Extra{from, false}); + g_recCache->replace(now, DNSName(templ), QType::AAAA, {aaaarr}, {}, {}, false, g_rootdnsname, std::nullopt, boost::none, vState::Insecure, MemRecursorCache::Extra{from, false}); } } } diff --git a/pdns/recursordist/reczones.cc b/pdns/recursordist/reczones.cc index 32f3806040..501c06b440 100644 --- a/pdns/recursordist/reczones.cc +++ b/pdns/recursordist/reczones.cc @@ -56,7 +56,7 @@ bool primeHints(time_t now) } g_recCache->doWipeCache(g_rootdnsname, false, QType::NS); - g_recCache->replace(now, g_rootdnsname, QType::NS, nsvec, {}, {}, false, g_rootdnsname, std::nullopt, std::nullopt, vState::Insecure, MemRecursorCache::Extra{ComboAddress("255.255.255.255"), false}); // and stuff in the cache + g_recCache->replace(now, g_rootdnsname, QType::NS, nsvec, {}, {}, false, g_rootdnsname, std::nullopt, boost::none, vState::Insecure, MemRecursorCache::Extra{ComboAddress("255.255.255.255"), false}); // and stuff in the cache return ret; } diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index c7fb1e1828..dadb92bfb6 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -4853,7 +4853,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& content.push_back(std::move(nonExpandedRecord)); } - g_recCache->replace(d_now.tv_sec, realOwner, QType(tCacheEntry->first.type), content, tCacheEntry->second.signatures, /* no additional records in that case */ {}, tCacheEntry->first.type == QType::DS ? true : isAA, auth, std::nullopt, std::nullopt, recordState, MemRecursorCache::Extra{remoteIP, overTCP}, d_refresh, tCacheEntry->second.d_ttl_time); + g_recCache->replace(d_now.tv_sec, realOwner, QType(tCacheEntry->first.type), content, tCacheEntry->second.signatures, /* no additional records in that case */ {}, tCacheEntry->first.type == QType::DS ? true : isAA, auth, std::nullopt, boost::none, recordState, MemRecursorCache::Extra{remoteIP, overTCP}, d_refresh, tCacheEntry->second.d_ttl_time); } } } diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index ec3d4798eb..322f502d5b 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -590,7 +590,7 @@ public: std::unordered_map d_discardedPolicies; DNSFilterEngine::Policy d_appliedPolicy; std::unordered_set d_policyTags; - std::optional d_routingTag; + boost::optional d_routingTag; ComboAddress d_fromAuthIP; RecEventTrace d_eventTrace; pdns::trace::InitialSpanInfo d_otTrace; diff --git a/pdns/recursordist/test-aggressive_nsec_cc.cc b/pdns/recursordist/test-aggressive_nsec_cc.cc index e4b5a3bebc..a9cca57a1b 100644 --- a/pdns/recursordist/test-aggressive_nsec_cc.cc +++ b/pdns/recursordist/test-aggressive_nsec_cc.cc @@ -1323,7 +1323,7 @@ static bool getDenialWrapper(std::unique_ptr& cache, time_t std::vector results; pdns::validation::ValidationContext validationContext; validationContext.d_nsec3IterationsRemainingQuota = std::numeric_limits::max(); - bool found = cache->getDenial(now, name, qtype, results, res, ComboAddress("192.0.2.1"), std::nullopt, true, validationContext); + bool found = cache->getDenial(now, name, qtype, results, res, ComboAddress("192.0.2.1"), boost::none, true, validationContext); if (expectedResult) { BOOST_CHECK_EQUAL(res, *expectedResult); } @@ -1356,7 +1356,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); - g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, std::nullopt, vState::Secure); + g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, boost::none, vState::Secure); BOOST_CHECK_EQUAL(g_recCache->size(), 1U); std::string oldSalt = "ab"; @@ -1473,7 +1473,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec_ancestor_cases) drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); - g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, std::nullopt, vState::Secure); + g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, boost::none, vState::Secure); BOOST_CHECK_EQUAL(g_recCache->size(), 1U); { @@ -1631,7 +1631,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_ancestor_cases) drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); - g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, std::nullopt, vState::Secure); + g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, boost::none, vState::Secure); BOOST_CHECK_EQUAL(g_recCache->size(), 1U); const std::string salt("ab"); @@ -1951,7 +1951,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_max_nsec3_hash_cost) drSOA.d_place = DNSResourceRecord::ANSWER; records.push_back(drSOA); - g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, std::nullopt, vState::Secure); + g_recCache->replace(now, zone, QType(QType::SOA), records, {}, {}, true, zone, std::nullopt, boost::none, vState::Secure); BOOST_CHECK_EQUAL(g_recCache->size(), 1U); auto insertNSEC3s = [zone, now](std::unique_ptr& cache, const std::string& salt, unsigned int iterationsCount) -> void { diff --git a/pdns/recursordist/test-recursorcache_cc.cc b/pdns/recursordist/test-recursorcache_cc.cc index 2036aa81a3..9eb591e20a 100644 --- a/pdns/recursordist/test-recursorcache_cc.cc +++ b/pdns/recursordist/test-recursorcache_cc.cc @@ -283,20 +283,20 @@ static void simple(time_t now) // insert Secure record records.push_back(dr2); - MRC.replace(now, power, QType(QType::A), records, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::Secure); + MRC.replace(now, power, QType(QType::A), records, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::Secure); BOOST_CHECK_EQUAL(MRC.size(), 1U); vState retrievedState = vState::Indeterminate; bool wasAuth = false; - BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), std::nullopt, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), (ttd - now)); + BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), boost::none, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), (ttd - now)); BOOST_CHECK_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(vStateToString(retrievedState), vStateToString(vState::Secure)); BOOST_CHECK_EQUAL(wasAuth, true); // try to replace that with a Bogus record - MRC.replace(now, power, QType(QType::A), records, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::BogusNoRRSIG); + MRC.replace(now, power, QType(QType::A), records, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::BogusNoRRSIG); BOOST_CHECK_EQUAL(MRC.size(), 1U); retrievedState = vState::Indeterminate; wasAuth = false; - BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), std::nullopt, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), (ttd - now)); + BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), boost::none, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), (ttd - now)); BOOST_CHECK_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(vStateToString(retrievedState), vStateToString(vState::Secure)); BOOST_CHECK_EQUAL(wasAuth, true); @@ -584,11 +584,11 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) /* the remaining entry should be power2, but to get it we need to go back in the past a bit */ - BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), 1); + BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), 1); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr2Content.toString()); /* check that power1 is gone */ - BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); /* clear everything up */ MRC.doWipeCache(DNSName("."), true); @@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) BOOST_CHECK_EQUAL(MRC.size(), 2U); /* trigger a miss (expired) for power2 */ - BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); /* power2 should have been moved to the front of the expunge queue, and should this time be removed first */ @@ -617,11 +617,11 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) /* the remaining entry should be power1, but to get it we need to go back in the past a bit */ - BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), 1); + BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), 1); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr1Content.toString()); /* check that power2 is gone */ - BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(ttd - 1, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); } BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) @@ -677,11 +677,11 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) BOOST_CHECK_EQUAL(MRC.size(), 1U); /* the remaining entry should be power2 */ - BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), ttd - now); + BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), ttd - now); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr2Content.toString()); /* check that power1 is gone */ - BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); /* clear everything up */ MRC.doWipeCache(DNSName("."), true); @@ -711,11 +711,11 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) BOOST_CHECK_EQUAL(MRC.size(), 1U); /* the remaining entry should be power1 */ - BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), ttd - now); + BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), ttd - now); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr1Content.toString()); /* check that power2 is gone */ - BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); /* clear everything up */ MRC.doWipeCache(DNSName("."), true); @@ -732,7 +732,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) BOOST_CHECK_EQUAL(MRC.size(), 2U); /* get a hit for power1 */ - BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), ttd - now); + BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), ttd - now); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr1Content.toString()); @@ -743,11 +743,11 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) BOOST_CHECK_EQUAL(MRC.size(), 1U); /* the remaining entry should be power1 */ - BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), ttd - now); + BOOST_CHECK_EQUAL(MRC.get(now, power1, QType(dr1.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), ttd - now); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr1Content.toString()); /* check that power2 is gone */ - BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, std::nullopt, nullptr), -1); + BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1); MRC.doPrune(now, 0); BOOST_CHECK_EQUAL(MRC.size(), 0U); @@ -1090,7 +1090,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) BOOST_CHECK_EQUAL(MRC.size(), 0U); // An entry without edns subnet gets stored without tag as well - MRC.replace(ttd, DNSName("hello"), QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, std::nullopt); + MRC.replace(ttd, DNSName("hello"), QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, boost::none); MRC.replace(ttd, DNSName("hello"), QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, string("mytag")); BOOST_CHECK_EQUAL(MRC.size(), 1U); BOOST_CHECK_EQUAL(MRC.doWipeCache(DNSName("hello"), false, QType::A), 1U); @@ -1118,7 +1118,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) int64_t expected = counter; for (counter = 0; counter < 110; counter++) { - if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, nobody, std::nullopt) > 0) { + if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, nobody, boost::none) > 0) { matches++; BOOST_CHECK_EQUAL(retrieved.size(), rset0.size()); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr0Content.toString()); @@ -1155,7 +1155,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) matches = 0; for (counter = 0; counter < 110; counter++) { - if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, nobody, std::nullopt) > 0) { + if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, nobody, boost::none) > 0) { matches++; BOOST_CHECK_EQUAL(retrieved.size(), rset0.size()); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr0Content.toString()); @@ -1239,7 +1239,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) BOOST_CHECK_EQUAL(retrieved.size(), 0U); // insert a new entry without tag - MRC.replace(now, power, QType(QType::A), rset2, signatures, authRecords, true, authZone, std::optional("192.0.3.0/24"), std::nullopt); + MRC.replace(now, power, QType(QType::A), rset2, signatures, authRecords, true, authZone, std::optional("192.0.3.0/24"), boost::none); BOOST_CHECK_EQUAL(MRC.size(), 2U); // tagged specific should be returned for a matching tag @@ -1248,28 +1248,28 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr1Content.toString()); // if no tag given nothing should be retrieved if address doesn't match - BOOST_CHECK_LT(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), std::nullopt), 0); + BOOST_CHECK_LT(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("127.0.0.1"), boost::none), 0); BOOST_REQUIRE_EQUAL(retrieved.size(), 0U); // if no tag given and no-non-tagged entries matches nothing should be returned - BOOST_CHECK_LT(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.2.2"), std::nullopt), 0); + BOOST_CHECK_LT(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.2.2"), boost::none), 0); BOOST_REQUIRE_EQUAL(retrieved.size(), 0U); // Insert untagged entry with no netmask - MRC.replace(now, power, QType(QType::A), rset3, signatures, authRecords, true, authZone, std::nullopt, std::nullopt); + MRC.replace(now, power, QType(QType::A), rset3, signatures, authRecords, true, authZone, std::nullopt, boost::none); BOOST_CHECK_EQUAL(MRC.size(), 3U); // Retrieval with no address and no tag should get that one - BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress(), std::nullopt), (ttd - now)); + BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress(), boost::none), (ttd - now)); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr3Content.toString()); // If no tag given match non-tagged entry - BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.2.2"), std::nullopt), (ttd - now)); + BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.2.2"), boost::none), (ttd - now)); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr3Content.toString()); // If no tag given we should be able to retrieve the netmask specific record - BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.3.1"), std::nullopt), (ttd - now)); + BOOST_CHECK_EQUAL(MRC.get(now, power, QType(QType::A), MemRecursorCache::None, &retrieved, ComboAddress("192.0.3.1"), boost::none), (ttd - now)); BOOST_REQUIRE_EQUAL(retrieved.size(), 1U); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr2Content.toString()); @@ -1333,7 +1333,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore) DNSName a = DNSName("hello ") + DNSName(std::to_string(counter)); BOOST_CHECK_EQUAL(DNSName(a.toString()), a); - MRC.replace(now, a, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::Insecure, authAddress, false, ttl_time); + MRC.replace(now, a, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::Insecure, authAddress, false, ttl_time); } BOOST_CHECK_EQUAL(MRC.size(), expected); @@ -1349,7 +1349,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore) bool wasAuth = false; DNSName fromZone; MemRecursorCache::Extra extra; - if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, somebody, std::nullopt, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { + if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, somebody, boost::none, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { matches++; BOOST_CHECK_EQUAL(retrieved.size(), rset0.size()); BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), dr0Content.toString()); @@ -1425,8 +1425,8 @@ BOOST_AUTO_TEST_CASE(test_RecursorAuthRecords) const time_t ttl_time = 90; DNSName aname = DNSName("hello "); - MRC.replace(now, aname, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::Insecure, authAddress, false, ttl_time); - MRC.replace(now, aname, QType(QType::AAAA), rset0, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::Insecure, authAddress, false, ttl_time); + MRC.replace(now, aname, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::Insecure, authAddress, false, ttl_time); + MRC.replace(now, aname, QType(QType::AAAA), rset0, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::Insecure, authAddress, false, ttl_time); std::vector retrieved; MemRecursorCache::AuthRecs authRecs; @@ -1436,7 +1436,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorAuthRecords) bool wasAuth = false; DNSName fromZone; MemRecursorCache::Extra extra; - if (MRC.get(now, aname, QType(QType::ANY), MemRecursorCache::None, &retrieved, somebody, std::nullopt, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { + if (MRC.get(now, aname, QType(QType::ANY), MemRecursorCache::None, &retrieved, somebody, boost::none, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { BOOST_CHECK_EQUAL(retrieved.size(), 2U); } } @@ -1537,7 +1537,7 @@ struct RecordsSpeedTest DNSName a = DNSName("hello ") + DNSName(std::to_string(counter)); BOOST_CHECK_EQUAL(DNSName(a.toString()), a); - MRC.replace(now, a, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, std::nullopt, vState::Insecure, MemRecursorCache::Extra{somebody, false}, false, ttl_time); + MRC.replace(now, a, QType(QType::A), rset0, signatures, authRecords, true, authZone, std::nullopt, boost::none, vState::Insecure, MemRecursorCache::Extra{somebody, false}, false, ttl_time); } BOOST_CHECK_EQUAL(MRC.size(), expected); @@ -1555,7 +1555,7 @@ struct RecordsSpeedTest bool wasAuth = false; DNSName fromZone; MemRecursorCache::Extra extra; - if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, somebody, std::nullopt, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { + if (MRC.get(now, DNSName("hello ") + DNSName(std::to_string(counter)), QType(QType::A), MemRecursorCache::None, &retrieved, somebody, boost::none, &sigs, &authRecs, &variable, &state, &wasAuth, &fromZone, &extra) > 0) { BOOST_CHECK_EQUAL(somebody.toString(), extra.d_address.toString()); BOOST_CHECK(!extra.d_tcp); matches++; diff --git a/pdns/recursordist/test-syncres_cc2.cc b/pdns/recursordist/test-syncres_cc2.cc index ea66bc6408..b46e41b65b 100644 --- a/pdns/recursordist/test-syncres_cc2.cc +++ b/pdns/recursordist/test-syncres_cc2.cc @@ -1851,12 +1851,12 @@ BOOST_AUTO_TEST_CASE(test_cache_almost_expired_ttl) std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.2", DNSResourceRecord::ANSWER, now + 29); - g_recCache->replace(now - 30, target, QType(QType::A), records, sigs, {}, true, g_rootdnsname, std::optional(), std::nullopt, vState::Indeterminate, std::nullopt, false, now - 31); + g_recCache->replace(now - 30, target, QType(QType::A), records, sigs, {}, true, g_rootdnsname, std::optional(), boost::none, vState::Indeterminate, std::nullopt, false, now - 31); /* Same for the NS record */ std::vector ns; addRecordToList(ns, target, QType::NS, "pdns-public-ns1.powerdns.com", DNSResourceRecord::ANSWER, now + 29); - g_recCache->replace(now - 30, target, QType::NS, ns, sigs, {}, false, target, std::optional(), std::nullopt, vState::Indeterminate, std::nullopt, false, now - 31); + g_recCache->replace(now - 30, target, QType::NS, ns, sigs, {}, false, target, std::optional(), boost::none, vState::Indeterminate, std::nullopt, false, now - 31); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); diff --git a/pdns/recursordist/test-syncres_cc3.cc b/pdns/recursordist/test-syncres_cc3.cc index 37404511bf..1f3101cc2c 100644 --- a/pdns/recursordist/test-syncres_cc3.cc +++ b/pdns/recursordist/test-syncres_cc3.cc @@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(test_answer_no_aa) const ComboAddress who; vector cached; MemRecursorCache::SigRecs signatures; - BOOST_REQUIRE_GT(g_recCache->get(now, target, QType(QType::A), MemRecursorCache::None, &cached, who, std::nullopt, &signatures), 0); + BOOST_REQUIRE_GT(g_recCache->get(now, target, QType(QType::A), MemRecursorCache::None, &cached, who, boost::none, &signatures), 0); } BOOST_AUTO_TEST_CASE(test_special_types) diff --git a/pdns/recursordist/test-syncres_cc8.cc b/pdns/recursordist/test-syncres_cc8.cc index 350071a941..49a5b631b1 100644 --- a/pdns/recursordist/test-syncres_cc8.cc +++ b/pdns/recursordist/test-syncres_cc8.cc @@ -1368,7 +1368,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) const ComboAddress who; vector cached; MemRecursorCache::SigRecs signatures; - BOOST_REQUIRE_EQUAL(g_recCache->get(tnow, target, QType(QType::A), MemRecursorCache::RequireAuth, &cached, who, std::nullopt, &signatures), 1); + BOOST_REQUIRE_EQUAL(g_recCache->get(tnow, target, QType(QType::A), MemRecursorCache::RequireAuth, &cached, who, boost::none, &signatures), 1); BOOST_REQUIRE_EQUAL(cached.size(), 1U); BOOST_REQUIRE_EQUAL(signatures->size(), 1U); BOOST_CHECK_EQUAL((cached[0].d_ttl - tnow), 1); diff --git a/pdns/recursordist/test-syncres_cc9.cc b/pdns/recursordist/test-syncres_cc9.cc index a472c71e43..1e28d6f06c 100644 --- a/pdns/recursordist/test-syncres_cc9.cc +++ b/pdns/recursordist/test-syncres_cc9.cc @@ -940,7 +940,7 @@ BOOST_AUTO_TEST_CASE(test_cname_plus_authority_ns_ttl) vector cached; bool wasAuth = false; - auto ttl = g_recCache->get(now, DNSName("powerdns.com."), QType(QType::NS), MemRecursorCache::None, &cached, who, std::nullopt, nullptr, nullptr, nullptr, nullptr, &wasAuth); + auto ttl = g_recCache->get(now, DNSName("powerdns.com."), QType(QType::NS), MemRecursorCache::None, &cached, who, boost::none, nullptr, nullptr, nullptr, nullptr, &wasAuth); BOOST_REQUIRE_GE(ttl, 1); BOOST_REQUIRE_LE(ttl, 42); BOOST_CHECK_EQUAL(cached.size(), 1U); @@ -949,7 +949,7 @@ BOOST_AUTO_TEST_CASE(test_cname_plus_authority_ns_ttl) cached.clear(); /* Also check that the part in additional is still not auth */ - BOOST_REQUIRE_GE(g_recCache->get(now, DNSName("a.gtld-servers.net."), QType(QType::A), MemRecursorCache::None, &cached, who, std::nullopt, nullptr, nullptr, nullptr, nullptr, &wasAuth), -1); + BOOST_REQUIRE_GE(g_recCache->get(now, DNSName("a.gtld-servers.net."), QType(QType::A), MemRecursorCache::None, &cached, who, boost::none, nullptr, nullptr, nullptr, nullptr, &wasAuth), -1); BOOST_CHECK_EQUAL(cached.size(), 1U); BOOST_CHECK_EQUAL(wasAuth, false); } @@ -1017,7 +1017,7 @@ BOOST_AUTO_TEST_CASE(test_bogus_does_not_replace_secure_in_the_cache) vector cached; bool wasAuth = false; vState retrievedState = vState::Insecure; - BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA), MemRecursorCache::RequireAuth, &cached, who, std::nullopt, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), 0); + BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA), MemRecursorCache::RequireAuth, &cached, who, boost::none, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), 0); BOOST_CHECK_EQUAL(vStateToString(retrievedState), vStateToString(vState::Secure)); BOOST_CHECK_EQUAL(wasAuth, true); @@ -1027,7 +1027,7 @@ BOOST_AUTO_TEST_CASE(test_bogus_does_not_replace_secure_in_the_cache) BOOST_REQUIRE_EQUAL(ret.size(), 2U); cached.clear(); - BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA), MemRecursorCache::RequireAuth, &cached, who, std::nullopt, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), 0); + BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA), MemRecursorCache::RequireAuth, &cached, who, boost::none, nullptr, nullptr, nullptr, &retrievedState, &wasAuth), 0); BOOST_CHECK_EQUAL(vStateToString(retrievedState), vStateToString(vState::Secure)); BOOST_CHECK_EQUAL(wasAuth, true); }