::arg().set("experimental-webserver-address", "IP Address of webserver to listen on") = "127.0.0.1";
::arg().set("experimental-webserver-port", "Port of webserver to listen on") = "8082";
::arg().set("experimental-webserver-password", "Password required for accessing the webserver") = "";
+ ::arg().set("experimental-api-config-dir", "Directory where REST API stores config and zones") = "";
::arg().set("quiet","Suppress logging of questions and answers")="";
::arg().set("logging-facility","Facility to log messages as. 0 corresponds to local0")="";
::arg().set("config-dir","Location of configuration directory (recursor.conf)")=SYSCONFDIR;
out.swap(stats);
}
+static void apiWriteConfigFile(const string& filebasename, const string& content)
+{
+ if (::arg()["experimental-api-config-dir"].empty()) {
+ throw ApiException("Config Option \"experimental-api-config-dir\" must be set");
+ }
+
+ string filename = ::arg()["experimental-api-config-dir"] + "/" + filebasename + ".conf";
+ ofstream ofconf(filename.c_str());
+ if (!ofconf) {
+ throw ApiException("Could not open config fragment file '"+filename+"' for writing: "+stringerror());
+ }
+ ofconf << "# Generated by pdns-recursor REST API, DO NOT EDIT" << endl;
+ ofconf << content << endl;
+ ofconf.close();
+}
+
RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm)
{
RecursorControlParser rcp; // inits