From 291729f38593951610020ba2fdf9c0f5bd92d6be Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 6 May 2016 09:43:11 +0200 Subject: [PATCH] implement a 'quiet' mode for SuffixMatchNodeRule() which prevents ShowRules() from listing a million domain names. --- pdns/README-dnsdist.md | 2 +- pdns/dnsdist-lua.cc | 4 ++-- pdns/dnsrulactions.hh | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pdns/README-dnsdist.md b/pdns/README-dnsdist.md index aef60cf2a..9949e20f6 100644 --- a/pdns/README-dnsdist.md +++ b/pdns/README-dnsdist.md @@ -1073,7 +1073,7 @@ instantiate a server with additional parameters * `QClassRule(qclass)`: matches queries with the specified qclass (numeric) * `QTypeRule(qtype)`: matches queries with the specified qtype * `RegexRule(regex)`: matches the query name against the supplied regex - * `SuffixMatchNodeRule()`: matches based on a group of domain suffixes for rapid testing of membership + * `SuffixMatchNodeRule(smn, [quiet-bool])`: matches based on a group of domain suffixes for rapid testing of membership. Pass `true` as second parameter to prevent listing of all domains matched. * `TCPRule(tcp)`: matches question received over TCP if `tcp` is true, over UDP otherwise * Rule management related: * `getAction(num)`: returns the Action associate with rule 'num'. diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 3322f6f6e..615491815 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -714,8 +714,8 @@ vector> setupLua(bool client, const std::string& confi }); #endif - g_lua.writeFunction("SuffixMatchNodeRule", [](const SuffixMatchNode& smn) { - return std::shared_ptr(new SuffixMatchNodeRule(smn)); + g_lua.writeFunction("SuffixMatchNodeRule", [](const SuffixMatchNode& smn, boost::optional quiet) { + return std::shared_ptr(new SuffixMatchNodeRule(smn, quiet ? *quiet : false)); }); g_lua.writeFunction("NetmaskGroupRule", [](const NetmaskGroup& nmg) { diff --git a/pdns/dnsrulactions.hh b/pdns/dnsrulactions.hh index 1a0578c95..5f60730d2 100644 --- a/pdns/dnsrulactions.hh +++ b/pdns/dnsrulactions.hh @@ -254,7 +254,7 @@ private: class SuffixMatchNodeRule : public DNSRule { public: - SuffixMatchNodeRule(const SuffixMatchNode& smn) : d_smn(smn) + SuffixMatchNodeRule(const SuffixMatchNode& smn, bool quiet=false) : d_smn(smn), d_quiet(quiet) { } bool matches(const DNSQuestion* dq) const override @@ -263,10 +263,14 @@ public: } string toString() const override { - return "qname=="+d_smn.toString(); + if(d_quiet) + return "qname==in-set"; + else + return "qname=="+d_smn.toString(); } private: SuffixMatchNode d_smn; + bool d_quiet; }; class QTypeRule : public DNSRule -- 2.40.0