]> granicus.if.org Git - pdns/commitdiff
add a NoRecurseRule, intended to strip queries of RD-bit over certain QPS rate (that...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 27 Aug 2015 15:12:58 +0000 (17:12 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 27 Aug 2015 15:12:58 +0000 (17:12 +0200)
pdns/dnsdist-lua.cc
pdns/dnsrulactions.hh

index 937c6b2ebfcc78b4ce0deae431e6d505bc3e06ee..63825f6af2970a69d2fb137843c75fb6b4cef4e9 100644 (file)
@@ -350,6 +350,17 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
                  std::make_shared<PoolAction>(pool)  });
          });
     });
+
+  g_lua.writeFunction("addNoRecurseRule", [](boost::variant<string,vector<pair<int, string>> > var) {
+      auto rule=makeRule(var);
+       g_rulactions.modify([rule](decltype(g_rulactions)::value_type& rulactions) {
+           rulactions.push_back({
+               rule,
+                 std::make_shared<NoRecurseAction>()  });
+         });
+    });
+
+
   g_lua.writeFunction("addQPSPoolRule", [](boost::variant<string,vector<pair<int, string>> > var, int limit, string pool) {
       auto rule = makeRule(var);
       g_rulactions.modify([rule, pool,limit](decltype(g_rulactions)::value_type& rulactions) {
index b5a7a505cbc825b84e24885405ab9cf655f2b5b6..83234e540f9734b9bda7e27bf6b646b8674bc804 100644 (file)
@@ -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";
+  }
+};