]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Recursor: Add api-config-dir config setting
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 7 Feb 2014 01:53:05 +0000 (02:53 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 7 Feb 2014 14:10:54 +0000 (15:10 +0100)
Prefixed experimental- for now.

pdns/pdns_recursor.cc
pdns/ws-recursor.cc

index c89a5174a713518675bed08b50197529f1f79b55..c30a5eada59187c83b9a263a2025dc84ed01bfa9 100644 (file)
@@ -2065,6 +2065,7 @@ int main(int argc, char **argv)
     ::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;
index 256c1bcdc5c49ea15e672ad3aa11712e2328bcad..e5b857dc2fbf1c6a3be06def1b77ac09570d7462 100644 (file)
@@ -44,6 +44,22 @@ void productServerStatisticsFetch(map<string,string>& out)
   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