mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-13 04:38:28 +00:00
local.conf in NodeConfig
This commit is contained in:
@ -109,10 +109,13 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsi
|
||||
LOG("unable to create network %.16llx: (unknown exception)",(unsigned long long)*nwid);
|
||||
}
|
||||
}
|
||||
|
||||
_readLocalConfig();
|
||||
}
|
||||
|
||||
NodeConfig::~NodeConfig()
|
||||
{
|
||||
_writeLocalConfig();
|
||||
}
|
||||
|
||||
void NodeConfig::clean()
|
||||
@ -122,6 +125,9 @@ void NodeConfig::clean()
|
||||
n->second->clean();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// UDP localhost control bus
|
||||
|
||||
// Macro used in execute() to push lines onto the return packet
|
||||
#undef _P
|
||||
#define _P(f,...) { r.push_back(std::string()); Utils::stdsprintf(r.back(),(f),##__VA_ARGS__); }
|
||||
@ -389,4 +395,21 @@ void NodeConfig::_CBcontrolPacketHandler(UdpSocket *sock,void *arg,const InetAdd
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void NodeConfig::_readLocalConfig()
|
||||
{
|
||||
std::string localDotConf(_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf");
|
||||
std::string buf;
|
||||
if (Utils::readFile(localDotConf.c_str(),buf)) {
|
||||
Mutex::Lock _l(_localConfig_m);
|
||||
_localConfig.fromString(buf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeConfig::_writeLocalConfig()
|
||||
{
|
||||
Utils::writeFile(((_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf")).c_str(),_localConfig.toString());
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
Reference in New Issue
Block a user