Make NetworkConfigMaster a plugin to get Redis and other non-endpoint code out of node/

This commit is contained in:
Adam Ierymenko 2015-02-24 12:28:58 -08:00
parent 93012b0ee5
commit ff255a34de
6 changed files with 214 additions and 99 deletions

View file

@ -108,9 +108,7 @@ struct _NodeImpl
delete renv.mc; renv.mc = (Multicaster *)0;
delete renv.antiRec; renv.antiRec = (AntiRecursion *)0;
delete renv.sw; renv.sw = (Switch *)0; // order matters less from here down
#ifdef ZT_ENABLE_NETCONF_MASTER
delete renv.netconfMaster; renv.netconfMaster = (NetworkConfigMaster *)0;
#endif
delete renv.http; renv.http = (HttpClient *)0;
delete renv.prng; renv.prng = (CMWC4096 *)0;
delete renv.log; renv.log = (Logger *)0; // but stop logging last of all
@ -310,21 +308,6 @@ Node::ReasonForTermination Node::run()
}
RR->node = this;
#ifdef ZT_ENABLE_NETCONF_MASTER
{
std::string redisHost(RR->nc->getLocalConfig(ZT_LOCAL_CONFIG_NETCONF_REDIS_HOST));
if (redisHost.length() > 0) {
unsigned int redisPort = Utils::strToUInt(RR->nc->getLocalConfig(ZT_LOCAL_CONFIG_NETCONF_REDIS_PORT).c_str());
if ((redisPort == 0)||(redisPort > 0xffff))
redisPort = ZT_LOCAL_CONFIG_NETCONF_REDIS_PORT_DEFAULT;
std::string redisAuth(RR->nc->getLocalConfig(ZT_LOCAL_CONFIG_NETCONF_REDIS_AUTH));
std::string redisDatabaseNumberStr(RR->nc->getLocalConfig(ZT_LOCAL_CONFIG_NETCONF_REDIS_DBNUM));
unsigned int redisDatabaseNumber = (redisDatabaseNumberStr.length() > 0) ? Utils::strToUInt(redisDatabaseNumberStr.c_str()) : (unsigned int)ZT_LOCAL_CONFIG_NETCONF_REDIS_DBNUM_DEFAULT;
RR->netconfMaster = new NetworkConfigMaster(RR,redisHost.c_str(),redisPort,redisAuth.c_str(),redisDatabaseNumber);
}
}
#endif
#ifdef ZT_AUTO_UPDATE
if (ZT_DEFAULTS.updateLatestNfoURL.length()) {
RR->updater = new SoftwareUpdater(RR);