From 8004d436b31f2d8dbdc1f02d22d12a598d055924 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 14 Sep 2020 11:30:42 +0200 Subject: [PATCH] Use boost::optional to pass optional cutoff point. This way the proper cutoff point can be specified for forwarded zones only, making it possible to change it meaning witjout regular nameserver lookups. (cherry picked from commit 96ce7d340951b31a3e3d042455a1f0e7f3a6eb56) --- pdns/syncres.cc | 6 +++--- pdns/syncres.hh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 9b18ea1fcd..33f8f1d986 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -725,7 +725,7 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector beenthereIgnored; - getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored, forwarded ? fwdomain : g_rootdnsname); + getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored, boost::make_optional(forwarded, fwdomain)); if (forwarded) { break; } @@ -1116,7 +1116,7 @@ vector SyncRes::getAddrs(const DNSName &qname, unsigned int depth, return ret; } -void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vector& bestns, bool* flawedNSSet, unsigned int depth, set& beenthere, const DNSName& cutOffDomain) +void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vector& bestns, bool* flawedNSSet, unsigned int depth, set& beenthere, const boost::optional& cutOffDomain) { string prefix; DNSName subdomain(qname); @@ -1127,7 +1127,7 @@ void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vecto bestns.clear(); bool brokeloop; do { - if (!subdomain.isPartOf(cutOffDomain)) { + if (cutOffDomain && (subdomain == *cutOffDomain || !subdomain.isPartOf(*cutOffDomain))) { break; } brokeloop=false; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index ca7154229b..95a9aace06 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -836,7 +836,7 @@ private: domainmap_t::const_iterator getBestAuthZone(DNSName* qname) const; bool doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector&ret, unsigned int depth, int &res, vState& state, bool wasAuthZone, bool wasForwardRecurse); bool doCacheCheck(const DNSName &qname, const DNSName& authname, bool wasForwardedOrAuthZone, bool wasAuthZone, bool wasForwardRecurse, const QType &qtype, vector&ret, unsigned int depth, int &res, vState& state); - void getBestNSFromCache(const DNSName &qname, const QType &qtype, vector&bestns, bool* flawedNSSet, unsigned int depth, set& beenthere, const DNSName& cutOffDomain = g_rootdnsname); + void getBestNSFromCache(const DNSName &qname, const QType &qtype, vector&bestns, bool* flawedNSSet, unsigned int depth, set& beenthere, const boost::optional& cutOffDomain = boost::none); DNSName getBestNSNamesFromCache(const DNSName &qname, const QType &qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set&beenthere); inline vector> shuffleInSpeedOrder(NsSet &nameservers, const string &prefix); -- 2.47.2