]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Expose typed cache flush via Web API
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 30 Sep 2020 08:24:33 +0000 (10:24 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 30 Sep 2020 08:24:33 +0000 (10:24 +0200)
pdns/recursordist/docs/http-api/endpoint-cache.rst
pdns/ws-recursor.cc

index bd2bea5ed1c37d2670567f9ca09d9f79b2f21447..a5d94d6d5eafc96d60205b0fd3997c2846d6bb39 100644 (file)
@@ -12,6 +12,10 @@ Cache manipulation endpoint
 
   :query subtree: If set to `true`, also flush the whole subtree (default = `false`)
 
+  .. versionadded:: 4.4.0
+
+  :query type: If set only flush records of the specified type name.
+
   **Example Response:**
 
   .. code-block:: json
index f24faad64492862677a35d857bd23ec24f6d588d..1e8dc0ed68d38fe1fddac199cc63b24d95b19fe3 100644 (file)
@@ -381,9 +381,13 @@ static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
 
   DNSName canon = apiNameToDNSName(req->getvars["domain"]);
   bool subtree = (req->getvars.count("subtree") > 0 && req->getvars["subtree"].compare("true") == 0);
+  uint16_t qtype = 0xffff;
+  if (req->getvars.count("type")) {
+    qtype = QType::chartocode(req->getvars["type"].c_str());
+  }
 
-  int count = g_recCache->doWipeCache(canon, subtree, 0xffff);
-  count += broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(canon, subtree, 0xffff);});
+  int count = g_recCache->doWipeCache(canon, subtree, qtype);
+  count += broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(canon, subtree, qtype);});
   count += g_negCache->wipe(canon, subtree);
   resp->setBody(Json::object {
     { "count", count },