From: Peter van Dijk Date: Thu, 4 Oct 2018 16:52:46 +0000 (+0200) Subject: remove api-logfile flag and grep API endpoint X-Git-Tag: dnsdist-1.3.3~49^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b49b4f2fd0108f3be73cf2a6ef15fb82e0b8787d;p=thirdparty%2Fpdns.git remove api-logfile flag and grep API endpoint --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index e4270e2901..7dfce29c5b 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -95,7 +95,6 @@ void declareArguments() ::arg().set("retrieval-threads", "Number of AXFR-retrieval threads for slave operation")="2"; ::arg().setSwitch("api", "Enable/disable the REST API (including HTTP listener)")="no"; ::arg().set("api-key", "Static pre-shared authentication key for access to the REST API")=""; - ::arg().set("api-logfile", "Location of the server logfile (used by the REST API)")="/var/log/pdns.log"; ::arg().setSwitch("dname-processing", "If we should support DNAME records")="no"; ::arg().setCmd("help","Provide a helpful message"); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index c3f10623ca..3c7ec0ee31 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3975,7 +3975,6 @@ int main(int argc, char **argv) ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")=""; ::arg().set("api-config-dir", "Directory where REST API stores config and zones") = ""; ::arg().set("api-key", "Static pre-shared authentication key for access to the REST API") = ""; - ::arg().set("api-logfile", "Location of the server logfile (used by the REST API)") = "/var/log/pdns.log"; ::arg().setSwitch("webserver", "Start a webserver (for REST API)") = "no"; ::arg().set("webserver-address", "IP Address of webserver to listen on") = "127.0.0.1"; ::arg().set("webserver-port", "Port of webserver to listen on") = "8082"; diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index 276365c257..7f82baf397 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -94,6 +94,8 @@ Disallow data modification through the REST API when set. ``api-logfile`` --------------- .. versionadded:: 4.0.0 +.. versionchanged:: 4.2.0 + This setting has been removed. - Path - Default: unset diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index 2df73657c4..54776cd1e3 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -155,53 +155,6 @@ void apiServerConfig(HttpRequest* req, HttpResponse* resp) { resp->setBody(doc); } -static Json logGrep(const string& q, const string& fname, const string& prefix) -{ - FILE* ptr = fopen(fname.c_str(), "r"); - if(!ptr) { - throw ApiException("Opening \"" + fname + "\" failed: " + stringerror()); - } - std::shared_ptr fp(ptr, fclose); - - string line; - string needle = q; - trim_right(needle); - - boost::replace_all(needle, "%20", " "); - boost::replace_all(needle, "%22", "\""); - - boost::tokenizer > t(needle, boost::escaped_list_separator("\\", " ", "\"")); - vector matches(t.begin(), t.end()); - matches.push_back(prefix); - - boost::circular_buffer lines(200); - while(stringfgets(fp.get(), line)) { - vector::const_iterator iter; - for(iter = matches.begin(); iter != matches.end(); ++iter) { - if(!strcasestr(line.c_str(), iter->c_str())) - break; - } - if(iter == matches.end()) { - trim_right(line); - lines.push_front(line); - } - } - - Json::array items; - for(const string& iline : lines) { - items.push_back(iline); - } - return items; -} - -void apiServerSearchLog(HttpRequest* req, HttpResponse* resp) { - if(req->method != "GET") - throw HttpMethodNotAllowedException(); - - string prefix = " " + s_programname + "["; - resp->setBody(logGrep(req->getvars["q"], ::arg()["api-logfile"], prefix)); -} - void apiServerStatistics(HttpRequest* req, HttpResponse* resp) { if(req->method != "GET") throw HttpMethodNotAllowedException(); diff --git a/pdns/ws-api.hh b/pdns/ws-api.hh index 1bbd6b55c2..0de6eda580 100644 --- a/pdns/ws-api.hh +++ b/pdns/ws-api.hh @@ -30,7 +30,6 @@ void apiDiscovery(HttpRequest* req, HttpResponse* resp); void apiServer(HttpRequest* req, HttpResponse* resp); void apiServerDetail(HttpRequest* req, HttpResponse* resp); void apiServerConfig(HttpRequest* req, HttpResponse* resp); -void apiServerSearchLog(HttpRequest* req, HttpResponse* resp); void apiServerStatistics(HttpRequest* req, HttpResponse* resp); // helpers diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index e025d2b434..1df76b1668 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -1955,7 +1955,6 @@ void AuthWebServer::webThread() if(::arg().mustDo("api")) { d_ws->registerApiHandler("/api/v1/servers/localhost/cache/flush", &apiServerCacheFlush); d_ws->registerApiHandler("/api/v1/servers/localhost/config", &apiServerConfig); - d_ws->registerApiHandler("/api/v1/servers/localhost/search-log", &apiServerSearchLog); d_ws->registerApiHandler("/api/v1/servers/localhost/search-data", &apiServerSearchData); d_ws->registerApiHandler("/api/v1/servers/localhost/statistics", &apiServerStatistics); d_ws->registerApiHandler("/api/v1/servers/localhost/zones//axfr-retrieve", &apiServerZoneAxfrRetrieve); diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 96b2549f70..3c3697fe5f 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -458,7 +458,6 @@ RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm) d_ws->registerApiHandler("/api/v1/servers/localhost/config/allow-from", &apiServerConfigAllowFrom); d_ws->registerApiHandler("/api/v1/servers/localhost/config", &apiServerConfig); d_ws->registerApiHandler("/api/v1/servers/localhost/rpzstatistics", &apiServerRPZStats); - d_ws->registerApiHandler("/api/v1/servers/localhost/search-log", &apiServerSearchLog); d_ws->registerApiHandler("/api/v1/servers/localhost/search-data", &apiServerSearchData); d_ws->registerApiHandler("/api/v1/servers/localhost/statistics", &apiServerStatistics); d_ws->registerApiHandler("/api/v1/servers/localhost/zones/", &apiServerZoneDetail);