From: Remi Gacogne Date: Fri, 6 Aug 2021 07:51:49 +0000 (+0200) Subject: rec: Pass the Lua context to follow up queries (follow CNAME, dns64) X-Git-Tag: dnsdist-1.7.0-alpha1~55^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4e9ad75186e883cdfcc87bc561a6e1f184d37f9;p=thirdparty%2Fpdns.git rec: Pass the Lua context to follow up queries (follow CNAME, dns64) --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 172421a34a..3b9ea54a85 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1416,7 +1416,7 @@ static void sendNODLookup(const DNSName& dname) return; } vector dummy; - directResolve(qname, QType::A, QClass::IN, dummy, false); + directResolve(qname, QType::A, QClass::IN, dummy, nullptr, false); } } @@ -1458,7 +1458,7 @@ int followCNAMERecords(vector& ret, const QType qtype, int rcode) return rcode; } - rcode = directResolve(target, qtype, QClass::IN, resolved); + rcode = directResolve(target, qtype, QClass::IN, resolved, t_pdl); for(DNSRecord& rr : resolved) { ret.push_back(std::move(rr)); @@ -1472,7 +1472,7 @@ int getFakeAAAARecords(const DNSName& qname, ComboAddress prefix, vector newRecords; - int rcode = directResolve(qname, QType::A, QClass::IN, newRecords); + int rcode = directResolve(qname, QType::A, QClass::IN, newRecords, t_pdl); ret.reserve(ret.size() + newRecords.size()); for (auto& record : newRecords) { @@ -1552,7 +1552,7 @@ int getFakePTRRecords(const DNSName& qname, vector& ret) rr.d_content = std::make_shared(newquery); ret.push_back(rr); - int rcode = directResolve(DNSName(newquery), QType::PTR, QClass::IN, ret); + int rcode = directResolve(DNSName(newquery), QType::PTR, QClass::IN, ret, t_pdl); return rcode; } diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 86ee77ae5b..2b93b59beb 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -4533,18 +4533,21 @@ void SyncRes::parseEDNSSubnetAddFor(const std::string& subnetlist) } // used by PowerDNSLua - note that this neglects to add the packet count & statistics back to pdns_recursor.cc -int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret) +int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, shared_ptr pdl) { - return directResolve(qname, qtype, qclass, ret, SyncRes::s_qnameminimization); + return directResolve(qname, qtype, qclass, ret, pdl, SyncRes::s_qnameminimization); } -int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, bool qm) +int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, shared_ptr pdl, bool qm) { struct timeval now; gettimeofday(&now, 0); SyncRes sr(now); sr.setQNameMinimization(qm); + if (pdl) { + sr.setLuaEngine(pdl); + } int res = -1; try { diff --git a/pdns/syncres.hh b/pdns/syncres.hh index a5f9caf4c0..f5a9fe59d1 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -1160,8 +1160,8 @@ typedef boost::function pipefunc_t; void broadcastFunction(const pipefunc_t& func); void distributeAsyncFunction(const std::string& question, const pipefunc_t& func); -int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret); -int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, bool qm); +int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, shared_ptr pdl); +int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector& ret, shared_ptr pdl, bool qm); int followCNAMERecords(std::vector& ret, const QType qtype, int oldret); int getFakeAAAARecords(const DNSName& qname, ComboAddress prefix, vector& ret); int getFakePTRRecords(const DNSName& qname, vector& ret);