From: Remi Gacogne Date: Fri, 3 Mar 2017 11:42:16 +0000 (+0100) Subject: rec: Constify SyncRes methods whenever possible X-Git-Tag: rec-4.1.0-alpha1~230^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69cbdef9f49f62bae02f0a630740f6db919bece2;p=thirdparty%2Fpdns.git rec: Constify SyncRes methods whenever possible --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 455aa014da..76cd5089dd 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -81,7 +81,7 @@ SyncRes::LogMode SyncRes::s_lm; bool SyncRes::s_noEDNS; -void accountAuthLatency(int usec, int family) +static void accountAuthLatency(int usec, int family) { if(family == AF_INET) { if(usec < 1000) @@ -324,7 +324,7 @@ void SyncRes::doEDNSDumpAndClose(int fd) For now this means we can't be clever, but will turn off DNSSEC if you reply with FormError or gibberish. */ -int SyncRes::asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional& srcmask, LWResult* res) +int SyncRes::asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional& srcmask, LWResult* res) const { /* what is your QUEST? the goal is to get as many remotes as possible on the highest level of EDNS support @@ -649,7 +649,7 @@ void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vecto }while(subdomain.chopOff()); } -SyncRes::domainmap_t::const_iterator SyncRes::getBestAuthZone(DNSName* qname) +SyncRes::domainmap_t::const_iterator SyncRes::getBestAuthZone(DNSName* qname) const { SyncRes::domainmap_t::const_iterator ret; do { @@ -874,7 +874,7 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vector b.countLabels()); } @@ -931,7 +931,7 @@ static bool magicAddrMatch(const QType& query, const QType& answer) } -recsig_t harvestRecords(const vector& records, const set& types) +static recsig_t harvestRecords(const vector& records, const set& types) { recsig_t ret; for(const auto& rec : records) { @@ -961,11 +961,11 @@ static void addNXNSECS(vector&ret, const vector& records) } } -bool SyncRes::nameserversBlockedByRPZ(const NsSet& nameservers) +bool SyncRes::nameserversBlockedByRPZ(const DNSFilterEngine& dfe, const NsSet& nameservers) { if(d_wantsRPZ) { for (auto const &ns : nameservers) { - d_appliedPolicy = g_luaconfs.getLocal()->dfe.getProcessingPolicy(ns.first, d_discardedPolicies); + d_appliedPolicy = dfe.getProcessingPolicy(ns.first, d_discardedPolicies); if (d_appliedPolicy.d_kind != DNSFilterEngine::PolicyKind::NoAction) { // client query needs an RPZ response LOG(", however nameserver "<dfe.getProcessingPolicy(address, d_discardedPolicies); + d_appliedPolicy = dfe.getProcessingPolicy(address, d_discardedPolicies); if (d_appliedPolicy.d_kind != DNSFilterEngine::PolicyKind::NoAction) { // client query needs an RPZ response LOG(", however nameserver "<dfe.getProcessingPolicy(remoteIP, d_discardedPolicies); + d_appliedPolicy = dfe.getProcessingPolicy(remoteIP, d_discardedPolicies); if (d_appliedPolicy.d_kind != DNSFilterEngine::PolicyKind::NoAction) { LOG(" (blocked by RPZ policy '"+(d_appliedPolicy.d_name ? *d_appliedPolicy.d_name : "")+"')"); return true; @@ -1264,6 +1264,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con vector&ret, unsigned int depth, set&beenthere) { + auto luaconfsLocal = g_luaconfs.getLocal(); string prefix; if(doLog()) { prefix=d_prefix; @@ -1272,7 +1273,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con LOG(prefix<dfe, nameservers)) { return -2; } @@ -1328,7 +1329,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con LOG(", "); } LOG(remoteIP->toString()); - if(nameserverIPBlockedByRPZ(*remoteIP)) { + if(nameserverIPBlockedByRPZ(luaconfsLocal->dfe, *remoteIP)) { hitPolicy = true; } } @@ -1517,7 +1518,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con nameservers.clear(); for (auto const &nameserver : nsset) { if (d_wantsRPZ) { - d_appliedPolicy = g_luaconfs.getLocal()->dfe.getProcessingPolicy(nameserver, d_discardedPolicies); + d_appliedPolicy = luaconfsLocal->dfe.getProcessingPolicy(nameserver, d_discardedPolicies); if (d_appliedPolicy.d_kind != DNSFilterEngine::PolicyKind::NoAction) { // client query needs an RPZ response LOG("however "<, BothRecordsAndSignatures> recsig_t; -recsig_t harvestRecords(const std::vector& records, const std::set& types); - - struct NegCacheEntry { DNSName d_name; @@ -308,7 +305,7 @@ public: d_lm = lm; } - bool doLog() + bool doLog() const { return d_lm != LogNone; } @@ -352,7 +349,7 @@ public: d_skipCNAMECheck = skip; } - int asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional& srcmask, LWResult* res); + int asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional& srcmask, LWResult* res) const; static void doEDNSDumpAndClose(int fd); @@ -524,18 +521,18 @@ private: unsigned int depth, set&beenthere); int doResolve(const DNSName &qname, const QType &qtype, vector&ret, unsigned int depth, set& beenthere); bool doOOBResolve(const DNSName &qname, const QType &qtype, vector&ret, unsigned int depth, int &res); - domainmap_t::const_iterator getBestAuthZone(DNSName* qname); + domainmap_t::const_iterator getBestAuthZone(DNSName* qname) const; bool doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector&ret, unsigned int depth, int &res); bool doCacheCheck(const DNSName &qname, const QType &qtype, vector&ret, unsigned int depth, int &res); void getBestNSFromCache(const DNSName &qname, const QType &qtype, vector&bestns, bool* flawedNSSet, unsigned int depth, set& beenthere); 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); - bool moreSpecificThan(const DNSName& a, const DNSName &b); + bool moreSpecificThan(const DNSName& a, const DNSName &b) const; vector getAddrs(const DNSName &qname, unsigned int depth, set& beenthere); - bool nameserversBlockedByRPZ(const NsSet& nameservers); - bool nameserverIPBlockedByRPZ(const ComboAddress&); + bool nameserversBlockedByRPZ(const DNSFilterEngine& dfe, const NsSet& nameservers); + bool nameserverIPBlockedByRPZ(const DNSFilterEngine& dfe, const ComboAddress&); bool throttledOrBlocked(const std::string& prefix, const ComboAddress& remoteIP, const DNSName& qname, const QType& qtype, bool pierceDontQuery); vector retrieveAddressesForNS(const std::string& prefix, const DNSName& qname, vector::const_iterator& tns, const unsigned int depth, set& beenthere, const vector& rnameservers, NsSet& nameservers, bool& sendRDQuery, bool& pierceDontQuery, bool& flawedNSSet);