#include "dnsseckeeper.hh"
static bool s_pleasequit;
+static string d_status;
bool DLQuitPlease()
{
exit(1);
}
+string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid)
+{
+ return ::arg().configstring(true);
+}
+
string DLRQuitHandler(const vector<string>&parts, Utility::pid_t ppid)
{
#ifndef WIN32
return ret;
}
-static string d_status;
void setStatus(const string &str)
{
L<<Logger::Error<<"Reload was requested"<<endl;
return "Ok";
}
+
bool DLQuitPlease();
+void setStatus(const string &str);
string DLQuitHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLRQuitHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLPingHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLShowHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLUptimeHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLSettingsHandler(const vector<string>&parts, Utility::pid_t ppid);
-void setStatus(const string &str);
string DLCCHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLStatusHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLNotifyHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLVersionHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLPurgeHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLNotifyRetrieveHandler(const vector<string>&parts, Utility::pid_t ppid);
+string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid);
#endif /* PDNS_DYNHANDLER_HH */
continue;
}
- if(d_tcp && !d_tcprange.match(&remote)) { // ????
+ if(d_tcp && !d_tcprange.match(&remote)) { // checks if the remote is within the permitted range.
L<<Logger::Error<<"Access denied to remote "<<remote.toString()<<" because not allowed"<<endl;
writen2(d_client, "Access denied to "+remote.toString()+"\n");
close(d_client);
void DynListener::theListener()
{
try {
- map<string,string> parameters;
signal(SIGPIPE,SIG_IGN);
for(int n=0;;++n) {
- // cerr<<"Reading new line, "<<d_client<<endl;
string line=getLine();
boost::trim_right(line);
sendLine("Empty line");
continue;
}
- parts[0] = toUpper( parts[0] );
- if(!s_funcdb.count(parts[0])) {
- if(parts[0] == "HELP")
- sendLine(getHelp());
- else if(s_restfunc)
- sendLine((*s_restfunc)(parts,d_ppid));
- else
- sendLine("Unknown command: '"+parts[0]+"'");
- continue;
- }
- sendLine((*(s_funcdb[parts[0]].func))(parts,d_ppid));
+ parts[0] = toUpper( parts[0] );
+ if(s_funcdb.count(parts[0])) {
+ cerr<<parts[0]<<" found in s_funcdb"<<endl;
+ sendLine((*(s_funcdb[parts[0]].func))(parts,d_ppid));
+ } else if (parts[0] == "HELP") {
+ sendLine(getHelp());
+ }else if(s_restfunc) {
+ cerr<<"Calling restfunction."<<endl;
+ sendLine((*s_restfunc)(parts,d_ppid));
+ } else
+ sendLine("Unknown command: '"+parts[0]+"'");
}
}
catch(AhuException &AE)
FILE *g_fp;
pthread_mutex_t g_guardian_lock = PTHREAD_MUTEX_INITIALIZER;
+// The next two methods are not in dynhandler.cc because they use a few items declared in this file.
+static string DLCycleHandler(const vector<string>&parts, pid_t ppid)
+{
+ kill(cpid, SIGKILL); // why?
+ kill(cpid, SIGKILL); // why?
+ sleep(1);
+ return "ok";
+}
+
static string DLRestHandler(const vector<string>&parts, pid_t ppid)
{
string line;
return response;
}
-static string DLCycleHandler(const vector<string>&parts, pid_t ppid)
-{
- kill(cpid, SIGKILL); // why?
- kill(cpid, SIGKILL); // why?
- sleep(1);
- return "ok";
-}
+
static int guardian(int argc, char **argv)
{
DynListener::registerFunc("CCOUNTS",&DLCCHandler, "get cache statistics");
DynListener::registerFunc("SET",&DLSettingsHandler, "set config variables", "<var> <value>");
DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", "<domain>");
+ DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "Retrieve the current configuration");
if(!::arg()["tcp-control-address"].empty()) {
DynListener* dlTCP=new DynListener(ComboAddress(::arg()["tcp-control-address"], ::arg().asNum("tcp-control-port")));