::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");
::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";
``api-logfile``
---------------
.. versionadded:: 4.0.0
+.. versionchanged:: 4.2.0
+ This setting has been removed.
- Path
- Default: unset
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<FILE> fp(ptr, fclose);
-
- string line;
- string needle = q;
- trim_right(needle);
-
- boost::replace_all(needle, "%20", " ");
- boost::replace_all(needle, "%22", "\"");
-
- boost::tokenizer<boost::escaped_list_separator<char> > t(needle, boost::escaped_list_separator<char>("\\", " ", "\""));
- vector<string> matches(t.begin(), t.end());
- matches.push_back(prefix);
-
- boost::circular_buffer<string> lines(200);
- while(stringfgets(fp.get(), line)) {
- vector<string>::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();
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
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/<id>/axfr-retrieve", &apiServerZoneAxfrRetrieve);
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/<id>", &apiServerZoneDetail);