::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("experimental-api-readonly", "If the JSON API should disallow data modification") = "no";
::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;
static void apiServerConfigAllowFrom(HttpRequest* req, HttpResponse* resp)
{
- if (req->method == "PUT") {
+ if (req->method == "PUT" && !::arg().mustDo("experimental-api-readonly")) {
Document document;
req->json(document);
const Value &jlist = document["value"];
static void apiServerZones(HttpRequest* req, HttpResponse* resp)
{
- if (req->method == "POST") {
+ if (req->method == "POST" && !::arg().mustDo("experimental-api-readonly")) {
if (::arg()["experimental-api-config-dir"].empty()) {
throw ApiException("Config Option \"experimental-api-config-dir\" must be set");
}
if (iter == t_sstorage->domainmap->end())
throw ApiException("Could not find domain '"+zonename+"'");
- if(req->method == "PUT") {
+ if(req->method == "PUT" && !::arg().mustDo("experimental-api-readonly")) {
Document document;
req->json(document);
reloadAuthAndForwards();
fillZone(stringFromJson(document, "name"), resp);
}
- else if(req->method == "DELETE") {
+ else if(req->method == "DELETE" && !::arg().mustDo("experimental-api-readonly")) {
if (!doDeleteZone(zonename)) {
throw ApiException("Deleting domain failed");
}