From 0570f37c272f7c468ae5d9fe302cd6109e77fab8 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 27 Aug 2015 17:12:58 +0200 Subject: [PATCH] add a NoRecurseRule, intended to strip queries of RD-bit over certain QPS rate (that part isn't there yet) --- pdns/dnsdist-lua.cc | 11 +++++++++++ pdns/dnsrulactions.hh | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 937c6b2eb..63825f6af 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -350,6 +350,17 @@ vector> setupLua(bool client, const std::string& confi std::make_shared(pool) }); }); }); + + g_lua.writeFunction("addNoRecurseRule", [](boost::variant> > var) { + auto rule=makeRule(var); + g_rulactions.modify([rule](decltype(g_rulactions)::value_type& rulactions) { + rulactions.push_back({ + rule, + std::make_shared() }); + }); + }); + + g_lua.writeFunction("addQPSPoolRule", [](boost::variant> > var, int limit, string pool) { auto rule = makeRule(var); g_rulactions.modify([rule, pool,limit](decltype(g_rulactions)::value_type& rulactions) { diff --git a/pdns/dnsrulactions.hh b/pdns/dnsrulactions.hh index b5a7a505c..83234e540 100644 --- a/pdns/dnsrulactions.hh +++ b/pdns/dnsrulactions.hh @@ -204,3 +204,17 @@ public: return "tc=1 answer"; } }; + +class NoRecurseAction : public DNSAction +{ +public: + DNSAction::Action operator()(const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh, int len, string* ruleresult) const override + { + dh->rd = false; + return Action::HeaderModify; + } + string toString() const override + { + return "rd=0 query"; + } +}; -- 2.40.0