From: Pieter Lexis Date: Wed, 26 Jun 2019 14:35:23 +0000 (+0200) Subject: dnsdist: Add `quiet` parameter to NetmaskGroupRule X-Git-Tag: dnsdist-1.4.0-rc1~91^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7fa60c9a90439442edb62fdbb9cfd60d0ff5109;p=thirdparty%2Fpdns.git dnsdist: Add `quiet` parameter to NetmaskGroupRule --- diff --git a/pdns/dnsdist-lua-rules.cc b/pdns/dnsdist-lua-rules.cc index b781e8c79a..98aae9ddb2 100644 --- a/pdns/dnsdist-lua-rules.cc +++ b/pdns/dnsdist-lua-rules.cc @@ -303,8 +303,8 @@ void setupLuaRules() return std::shared_ptr(new SuffixMatchNodeRule(smn, quiet ? *quiet : false)); }); - g_lua.writeFunction("NetmaskGroupRule", [](const NetmaskGroup& nmg, boost::optional src) { - return std::shared_ptr(new NetmaskGroupRule(nmg, src ? *src : true)); + g_lua.writeFunction("NetmaskGroupRule", [](const NetmaskGroup& nmg, boost::optional src, boost::optional quiet) { + return std::shared_ptr(new NetmaskGroupRule(nmg, src ? *src : true, quiet ? *quiet : false)); }); g_lua.writeFunction("benchRule", [](std::shared_ptr rule, boost::optional times_, boost::optional suffix_) { diff --git a/pdns/dnsdistdist/dnsdist-rules.hh b/pdns/dnsdistdist/dnsdist-rules.hh index 4827a6aa02..1d9944e527 100644 --- a/pdns/dnsdistdist/dnsdist-rules.hh +++ b/pdns/dnsdistdist/dnsdist-rules.hh @@ -183,9 +183,10 @@ protected: class NetmaskGroupRule : public NMGRule { public: - NetmaskGroupRule(const NetmaskGroup& nmg, bool src) : NMGRule(nmg) + NetmaskGroupRule(const NetmaskGroup& nmg, bool src, bool quiet = false) : NMGRule(nmg) { d_src = src; + d_quiet = quiet; } bool matches(const DNSQuestion* dq) const override { @@ -197,13 +198,18 @@ public: string toString() const override { + string ret = "Src: "; if(!d_src) { - return "Dst: "+d_nmg.toString(); + ret = "Dst: "; } - return "Src: "+d_nmg.toString(); + if (d_quiet) { + return ret + "in-group"; + } + return ret + d_nmg.toString(); } private: bool d_src; + bool d_quiet; }; class TimedIPSetRule : public DNSRule, boost::noncopyable diff --git a/pdns/dnsdistdist/docs/rules-actions.rst b/pdns/dnsdistdist/docs/rules-actions.rst index 58eff1c9c1..26c8d4cc89 100644 --- a/pdns/dnsdistdist/docs/rules-actions.rst +++ b/pdns/dnsdistdist/docs/rules-actions.rst @@ -613,7 +613,10 @@ These ``DNSRule``\ s be one of the following items: :param int qps: The number of queries per second allowed, above this number the traffic is **not** matched anymore -.. function:: NetmaskGroupRule(nmg[, src]) +.. function:: NetmaskGroupRule(nmg[, src[, quiet]]) + + .. versionchanged:: 1.4.0 + ``quiet`` parameter added Matches traffic from/to the network range specified in ``nmg``. @@ -622,6 +625,7 @@ These ``DNSRule``\ s be one of the following items: :param NetMaskGroup nmg: The NetMaskGroup to match on :param bool src: Whether to match source or destination address of the packet. Defaults to true (matches source) + :param bool quiet: Do not return the list of matched netmasks. Default is false. .. function:: OpcodeRule(code)