From: Pieter Lexis Date: Fri, 20 Mar 2020 12:44:40 +0000 (+0100) Subject: dnsdist: expose SuffixMatchNode::remove in Lua X-Git-Tag: dnsdist-1.5.0-rc1~31^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc5c693b1cf700da1b67529247976fb46f9208b6;p=thirdparty%2Fpdns.git dnsdist: expose SuffixMatchNode::remove in Lua --- diff --git a/pdns/dnsdist-lua-bindings.cc b/pdns/dnsdist-lua-bindings.cc index 4c26647b07..3089936fee 100644 --- a/pdns/dnsdist-lua-bindings.cc +++ b/pdns/dnsdist-lua-bindings.cc @@ -258,6 +258,35 @@ void setupLuaBindings(bool client) return; } }); + g_lua.registerFunction>, vector>> &name)>("remove", [](SuffixMatchNode &smn, const boost::variant>, vector>> &name) { + if (name.type() == typeid(DNSName)) { + auto n = boost::get(name); + smn.remove(n); + return; + } + if (name.type() == typeid(string)) { + auto n = boost::get(name); + DNSName d(n); + smn.remove(d); + return; + } + if (name.type() == typeid(vector>)) { + auto names = boost::get>>(name); + for (auto const n : names) { + smn.remove(n.second); + } + return; + } + if (name.type() == typeid(vector>)) { + auto names = boost::get>>(name); + for (auto const n : names) { + DNSName d(n.second); + smn.remove(d); + } + return; + } + }); + g_lua.registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check); /* Netmask */ diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index cb47ee0fc3..dca06dddd4 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -1273,6 +1273,16 @@ If you are looking for exact name matching, your might want to consider using a :param string name: The suffix to add to the set. :param table name: The suffixes to add to the set. Elements of the table should be of the same type, either DNSName or string. + .. method:: SuffixMatchNode:remove(name) + + .. versionadded:: 1.5.0 + + Remove a suffix from the current set. + + :param DNSName name: The suffix to remove from the set. + :param string name: The suffix to remove from the set. + :param table name: The suffixes to remove from the set. Elements of the table should be of the same type, either DNSName or string. + .. method:: SuffixMatchNode:check(name) -> bool Return true if the given name is a sub-domain of one of those in the set, and false otherwise.