]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add & document QNameRule
authorbert hubert <bert.hubert@powerdns.com>
Mon, 10 Apr 2017 17:23:49 +0000 (19:23 +0200)
committerbert hubert <bert.hubert@powerdns.com>
Tue, 11 Apr 2017 11:45:52 +0000 (13:45 +0200)
pdns/README-dnsdist.md
pdns/dnsdist-console.cc
pdns/dnsdist-lua.cc
pdns/dnsrulactions.hh

index 04e25eabcf4e758b3445ca62c1124610c6e5a8b6..6ae77d63fc51cc79be537fb73e158ff5a23abb44 100644 (file)
@@ -343,6 +343,7 @@ Rules have selectors and actions. Current selectors are:
  * QPS Limit total
  * QPS Limit per IP address or subnet
  * QClass (QClassRule)
+ * QName (QNameRule)
  * QType (QTypeRule)
  * RegexRule on query name
  * RE2Rule on query name (optional)
@@ -427,6 +428,7 @@ A DNS rule can be:
  * an OrRule
  * a QClassRule
  * a QNameLabelsCountRule
+ * a QNameRule
  * a QNameWireLengthRule
  * a QTypeRule
  * a RCodeRule
@@ -1411,6 +1413,7 @@ instantiate a server with additional parameters
     * `OpcodeRule()`: matches queries with the specified opcode
     * `QClassRule(qclass)`: matches queries with the specified qclass (numeric)
     * `QNameLabelsCountRule(min, max)`: matches if the qname has less than `min` or more than `max` labels
+    * `QNameRule(qname)`: matches queries with the specified qname
     * `QNameWireLengthRule(min, max)`: matches if the qname's length on the wire is less than `min` or more than `max` bytes
     * `QTypeRule(qtype)`: matches queries with the specified qtype
     * `RCodeRule(rcode)`: matches queries or responses the specified rcode
index bc4febd4a6cf11fcf2259c42bea34629b832701a..167d0310952b9659778234d1842161d7caa627ef 100644 (file)
@@ -349,6 +349,7 @@ const std::vector<ConsoleKeyword> g_consoleKeywords{
   { "rmServer", true, "n", "remove server with index n" },
   { "roundrobin", false, "", "Simple round robin over available servers" },
   { "QNameLabelsCountRule", true, "min, max", "matches if the qname has less than `min` or more than `max` labels" },
+  { "QNameRule", true, "qname", "matches queries with the specified qname" },
   { "QNameWireLengthRule", true, "min, max", "matches if the qname's length on the wire is less than `min` or more than `max` bytes" },
   { "QTypeRule", true, "qtype", "matches queries with the specified qtype" },
   { "RCodeRule", true, "rcode", "matches responses with the specified rcode" },
index fe0abd01be683d969a43fb96c31dca68f20dae49..6723e9700c72b64c3f319d39427d885079a20cc2 100644 (file)
@@ -922,6 +922,10 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
       return std::shared_ptr<DNSRule>(new AllRule());
     });
 
+  g_lua.writeFunction("QNameRule", [](const std::string& qname) {
+      return std::shared_ptr<DNSRule>(new QNameRule(DNSName(qname)));
+    });
+  
   g_lua.writeFunction("QTypeRule", [](boost::variant<int, std::string> str) {
       uint16_t qtype;
       if(auto dir = boost::get<int>(&str)) {
index eec9cb24b5956a6706f19162ee4c24310a32be6e..a9cf5e50defce8bf03d2f0387bf36c64d9085d75 100644 (file)
@@ -300,13 +300,32 @@ public:
     if(d_quiet)
       return "qname==in-set";
     else
-      return "qname=="+d_smn.toString();
+      return "qname in "+d_smn.toString();
   }
 private:
   SuffixMatchNode d_smn;
   bool d_quiet;
 };
 
+class QNameRule : public DNSRule
+{
+public:
+  QNameRule(const DNSName& qname) : d_qname(qname)
+  {
+  }
+  bool matches(const DNSQuestion* dq) const override
+  {
+    return d_qname==*dq->qname;
+  }
+  string toString() const override
+  {
+    return "qname=="+d_qname.toString();
+  }
+private:
+  DNSName d_qname;
+};
+
+
 class QTypeRule : public DNSRule
 {
 public: