Skip to content

Commit

Permalink
Implement directBackendCmd in remotebackend
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Jun 30, 2015
1 parent 78903c5 commit 0bcb7cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/remotebackend/httpconnector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ void HTTPConnector::restful_requestbuilder(const std::string &method, const rapi
req.POST()["serial"] = sparam;
req.preparePost();
verb = "PATCH";
} else if (method == "directBackendCmd") {
json2string(parameters["query"],sparam);
req.POST()["query"] = sparam;
req.preparePost();
verb = "POST";
} else {
// perform normal get
verb = "GET";
Expand Down
16 changes: 16 additions & 0 deletions modules/remotebackend/remotebackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,22 @@ bool RemoteBackend::calculateSOASerial(const string& domain, const SOAData& sd,
return true;
}

string RemoteBackend::directBackendCmd(const string& querystr) {
rapidjson::Document query,answer;
rapidjson::Value parameters;

query.SetObject();
JSON_ADD_MEMBER(query, "method", "directBackendCmd", query.GetAllocator());
parameters.SetObject();
JSON_ADD_MEMBER(parameters, "query", querystr.c_str(), query.GetAllocator());
query.AddMember("parameters", parameters, query.GetAllocator());

if (this->send(query) == false || this->recv(answer) == false)
return "backend command failed";

return getString(answer["result"]);
}

// some rapidjson helpers
bool RemoteBackend::getBool(rapidjson::Value &value) {
if (value.IsNull()) return false;
Expand Down
1 change: 1 addition & 0 deletions modules/remotebackend/remotebackend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class RemoteBackend : public DNSBackend
virtual bool setTSIGKey(const string& name, const string& algorithm, const string& content);
virtual bool deleteTSIGKey(const string& name);
virtual bool getTSIGKeys(std::vector< struct TSIGKey > &keys);
virtual string directBackendCmd(const string& querystr);

static DNSBackend *maker();

Expand Down

0 comments on commit 0bcb7cc

Please sign in to comment.