From: bert hubert Date: Sun, 17 Jan 2016 09:49:03 +0000 (+0100) Subject: add makeRule convenience function, improve SuffixMatchNodeRule showRules() output... X-Git-Tag: dnsdist-1.0.0-alpha2~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecc8a33badc40017837d76ee49596f3667ecda8e;p=pdns add makeRule convenience function, improve SuffixMatchNodeRule showRules() output, document this --- diff --git a/pdns/README-dnsdist.md b/pdns/README-dnsdist.md index ce6ee9d05..b4bdef515 100644 --- a/pdns/README-dnsdist.md +++ b/pdns/README-dnsdist.md @@ -305,16 +305,16 @@ Rules have selectors and actions. Current selectors are: A special rule is `AndRule{rule1, rule2}`, which only matches if all of its subrules match. Current actions are: - * Drop - * Route to a pool + * Drop (DropAction) + * Route to a pool (PoolAction) * Return with TC=1 (truncated, ie, instruction to retry with TCP) * Force a ServFail, NotImp or Refused answer * Send out a crafted response (NXDOMAIN or "real" data) - * Delay a response by n milliseconds + * Delay a response by n milliseconds (DelayAction) * Modify query to remove RD bit Rules can be added via: - * addAction(DNS rule) + * addAction(DNS rule, DNS Action) * addAnyTCRule() * addDelay(DNS rule, delay in milliseconds) * addDisableValidationRule(DNS rule) @@ -337,6 +337,10 @@ A DNS rule can be: * a RegexRule * a SuffixMatchNodeRule +A convenience function `makeRule()` is supplied which will make a NetmaskGroupRule for you or a SuffixMatchNodeRule +depending on how you call it. `makeRule("0.0.0.0/0")` will for example match all IPv4 traffic, `makeRule{"be","nl","lu"}` will +match all Benelux DNS traffic. + More power ---------- More powerful things can be achieved by defining a function called diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 249483b7c..38f48aa52 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -311,7 +311,7 @@ vector> setupLua(bool client, const std::string& confi return ret; } ); - + g_lua.writeFunction("makeRule", makeRule); g_lua.writeFunction("addAnyTCRule", []() { setLuaSideEffect(); auto rules=g_rulactions.getCopy(); diff --git a/pdns/dnsrulactions.hh b/pdns/dnsrulactions.hh index 9f065502a..b242b709d 100644 --- a/pdns/dnsrulactions.hh +++ b/pdns/dnsrulactions.hh @@ -186,7 +186,7 @@ public: } string toString() const override { - return d_smn.toString(); + return "qname=="+d_smn.toString(); } private: SuffixMatchNode d_smn;