Config* config;
char* cfgDocRoot;
char* cfgPort;
+ char* cfgSSLFilename;
+ bool mgRunning;
public:
cPluginJsonserver(void);
virtual ~cPluginJsonserver();
log = NULL;
cfgDocRoot = NULL;
cfgPort = NULL;
+ cfgSSLFilename = NULL;
+ mgRunning = false;
}
cPluginJsonserver::~cPluginJsonserver()
cfgPort = new char[5];
strcpy(cfgPort, "8005");
}
+
+ char* cfgSSLFilename = config->getValueString("General", "SSL PEM File");
+ if (!cfgSSLFilename)
+ {
+ log->log("Main", Log::ALERT, "Config General / SSL PEM File not found - can't run!");
+ dsyslog("jsonserver: ERROR: Config: SSL PEM not found");
+ delete log;
+ delete config;
+ log = NULL;
+ config = NULL;
+ return false;
+ }
// Make Mongoose options
const char *options[] =
"num_threads", "5",
"listening_ports", "8005s",
- "ssl_certificate", "/opt/jsonserver/sslcert.pem",
+ "ssl_certificate", cfgSSLFilename,
// "auth_domain", "VDRWeb",
mg = mg_start(&callbacks, NULL, options);
log->log("JSONServer", Log::INFO, "Mongoose started");
+ mgRunning = true;
return true;
}
void cPluginJsonserver::Stop(void)
{
// Stop any background activities the plugin is performing.
- mg_stop(mg);
+ if (mgRunning) mg_stop(mg);
+ mgRunning = false;
if (cfgDocRoot) delete[] cfgDocRoot; cfgDocRoot = NULL;
if (cfgPort) delete[] cfgPort; cfgPort = NULL;
+ if (cfgSSLFilename) delete[] cfgSSLFilename; cfgSSLFilename = NULL;
}
void cPluginJsonserver::Housekeeping(void)