From: Otto Moerbeek Date: Mon, 14 Sep 2020 09:30:42 +0000 (+0200) Subject: Use boost::optional to pass optional cutoff point. This way the X-Git-Tag: rec-4.5.0-alpha0~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9448%2Fhead;p=thirdparty%2Fpdns.git 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. --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 1973bd8b1a..07cd25c03d 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);