From: bert hubert Date: Fri, 15 Jan 2016 20:23:50 +0000 (+0100) Subject: Merge pull request #3233 from rgacogne/dnsdist-dq X-Git-Tag: dnsdist-1.0.0-alpha2~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e054e93838c904b1c5367f883c534a50ae02509;p=pdns Merge pull request #3233 from rgacogne/dnsdist-dq dnsdist: Replace the Lua params with a DNSQuestion `dq` object --- 7e054e93838c904b1c5367f883c534a50ae02509 diff --cc pdns/dnsdist.hh index 81dc83f32,06c1ff503..49fab7cd1 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@@ -433,14 -447,13 +447,14 @@@ void controlThread(int fd, ComboAddres vector> setupLua(bool client, const std::string& config); NumberedServerVector getDownstreamCandidates(const servers_t& servers, const std::string& pool); - std::shared_ptr firstAvailable(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh); + std::shared_ptr firstAvailable(const NumberedServerVector& servers, const DNSQuestion* dq); - std::shared_ptr leastOutstanding(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh); - std::shared_ptr wrandom(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh); - std::shared_ptr whashed(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh); - std::shared_ptr roundrobin(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh); + std::shared_ptr leastOutstanding(const NumberedServerVector& servers, const DNSQuestion* dq); + std::shared_ptr wrandom(const NumberedServerVector& servers, const DNSQuestion* dq); + std::shared_ptr whashed(const NumberedServerVector& servers, const DNSQuestion* dq); + std::shared_ptr roundrobin(const NumberedServerVector& servers, const DNSQuestion* dq); int getEDNSZ(const char* packet, unsigned int len); +void spoofResponseFromString(const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh, uint16_t& len, uint16_t querySize, const string& spoofContent); uint16_t getEDNSOptionCode(const char * packet, size_t len); void dnsdistWebserverThread(int sock, const ComboAddress& local, const string& password); bool getMsgLen32(int fd, uint32_t* len); diff --cc pdns/dnsrulactions.hh index 3b14651df,d04d83d1c..9f065502a --- a/pdns/dnsrulactions.hh +++ b/pdns/dnsrulactions.hh @@@ -356,20 -356,12 +356,21 @@@ public class SpoofAction : public DNSAction { public: - SpoofAction(const ComboAddress& a) : d_a(a) { d_aaaa.sin4.sin_family = 0;} + SpoofAction(const ComboAddress& a) + { + if (a.sin4.sin_family == AF_INET) { + d_a = a; + d_aaaa.sin4.sin_family = 0; + } else { + d_a.sin4.sin_family = 0; + d_aaaa = a; + } + } SpoofAction(const ComboAddress& a, const ComboAddress& aaaa) : d_a(a), d_aaaa(aaaa) {} SpoofAction(const string& cname): d_cname(cname) { d_a.sin4.sin_family = 0; d_aaaa.sin4.sin_family = 0; } - DNSAction::Action operator()(const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh, uint16_t& len, uint16_t bufferSize, string* ruleresult) const override + DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override { + uint16_t qtype = dq->qtype; if(d_cname.empty() && ((qtype == QType::A && d_a.sin4.sin_family == 0) || (qtype == QType::AAAA && d_aaaa.sin4.sin_family == 0) || (qtype != QType::A && qtype != QType::AAAA)))