]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: expose SuffixMatchNode::remove in Lua 8956/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 20 Mar 2020 12:44:40 +0000 (13:44 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 20 Mar 2020 12:44:40 +0000 (13:44 +0100)
pdns/dnsdist-lua-bindings.cc
pdns/dnsdistdist/docs/reference/config.rst

index 4c26647b075d35e22b06467aa72f712f82973d17..3089936feed4b03bc2b99d2926327f7e2b671371 100644 (file)
@@ -258,6 +258,35 @@ void setupLuaBindings(bool client)
           return;
       }
   });
+  g_lua.registerFunction<void (SuffixMatchNode::*)(const boost::variant<DNSName, string, vector<pair<int, DNSName>>, vector<pair<int, string>>> &name)>("remove", [](SuffixMatchNode &smn, const boost::variant<DNSName, string, vector<pair<int, DNSName>>, vector<pair<int, string>>> &name) {
+      if (name.type() == typeid(DNSName)) {
+          auto n = boost::get<DNSName>(name);
+          smn.remove(n);
+          return;
+      }
+      if (name.type() == typeid(string)) {
+          auto n = boost::get<string>(name);
+          DNSName d(n);
+          smn.remove(d);
+          return;
+      }
+      if (name.type() == typeid(vector<pair<int, DNSName>>)) {
+          auto names = boost::get<vector<pair<int, DNSName>>>(name);
+          for (auto const n : names) {
+            smn.remove(n.second);
+          }
+          return;
+      }
+      if (name.type() == typeid(vector<pair<int, string>>)) {
+          auto names = boost::get<vector<pair<int, string>>>(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 */
index cb47ee0fc370f53f6525a6b64766853982dfd502..dca06dddd4fd8f782a73c100b3526f0d0299965d 100644 (file)
@@ -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.