]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Accept string in DNSDistPacketCache:expungeByName 9428/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 31 Aug 2020 12:44:19 +0000 (14:44 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 31 Aug 2020 12:50:58 +0000 (14:50 +0200)
pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc
pdns/dnsdistdist/docs/reference/config.rst

index 27c20b41b0b773ce27e88c5d52050184031c6abe..b6d687a759611ef6e5eb82c4f0a59e3d5e44407d 100644 (file)
@@ -116,13 +116,20 @@ void setupLuaBindingsPacketCache()
       }
       return static_cast<size_t>(0);
     });
-  g_lua.registerFunction<void(std::shared_ptr<DNSDistPacketCache>::*)(const DNSName& dname, boost::optional<uint16_t> qtype, boost::optional<bool> suffixMatch)>("expungeByName", [](
+  g_lua.registerFunction<void(std::shared_ptr<DNSDistPacketCache>::*)(const boost::variant<DNSName, string>& dname, boost::optional<uint16_t> qtype, boost::optional<bool> suffixMatch)>("expungeByName", [](
               std::shared_ptr<DNSDistPacketCache>& cache,
-              const DNSName& dname,
+              const boost::variant<DNSName, string>& dname,
               boost::optional<uint16_t> qtype,
               boost::optional<bool> suffixMatch) {
+                DNSName qname;
+                if (dname.type() == typeid(DNSName)) {
+                  qname = boost::get<DNSName>(dname);
+                }
+                if (dname.type() == typeid(string)) {
+                  qname = DNSName(boost::get<string>(dname));
+                }
                 if (cache) {
-                  g_outputBuffer="Expunged " + std::to_string(cache->expungeByName(dname, qtype ? *qtype : QType(QType::ANY).getCode(), suffixMatch ? *suffixMatch : false)) + " records\n";
+                  g_outputBuffer="Expunged " + std::to_string(cache->expungeByName(qname, qtype ? *qtype : QType(QType::ANY).getCode(), suffixMatch ? *suffixMatch : false)) + " records\n";
                 }
     });
   g_lua.registerFunction<void(std::shared_ptr<DNSDistPacketCache>::*)()>("printStats", [](const std::shared_ptr<DNSDistPacketCache>& cache) {
index 8487126c9c521589daef4028e01de147221ecbae..7c3667e7902dffca76216c1698411036784a2532 100644 (file)
@@ -746,6 +746,9 @@ See :doc:`../guides/cache` for a how to.
     .. versionchanged:: 1.2.0
       ``suffixMatch`` parameter added.
 
+    .. versionchanged:: 1.6.0
+      ``name`` can now also be a string
+
     Remove entries matching ``name`` and type from the cache.
 
     :param DNSName name: The name to expunge