From: Otto Moerbeek Date: Wed, 30 Sep 2020 08:24:33 +0000 (+0200) Subject: Expose typed cache flush via Web API X-Git-Tag: auth-4.4.0-alpha2~57^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bb2d9875c82776d91c2c7a7d4de1a8ce8ed3097;p=thirdparty%2Fpdns.git Expose typed cache flush via Web API --- diff --git a/pdns/recursordist/docs/http-api/endpoint-cache.rst b/pdns/recursordist/docs/http-api/endpoint-cache.rst index bd2bea5ed1..a5d94d6d5e 100644 --- a/pdns/recursordist/docs/http-api/endpoint-cache.rst +++ b/pdns/recursordist/docs/http-api/endpoint-cache.rst @@ -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 diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index f24faad644..1e8dc0ed68 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -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([=]{return pleaseWipePacketCache(canon, subtree, 0xffff);}); + int count = g_recCache->doWipeCache(canon, subtree, qtype); + count += broadcastAccFunction([=]{return pleaseWipePacketCache(canon, subtree, qtype);}); count += g_negCache->wipe(canon, subtree); resp->setBody(Json::object { { "count", count },