More cleanup.

This commit is contained in:
Adam Ierymenko 2015-04-01 19:15:21 -07:00
parent 1f28ce3980
commit 0214dbc277
2 changed files with 15 additions and 32 deletions

View File

@ -100,15 +100,28 @@ Network::Network(const RuntimeEnvironment *renv,uint64_t nwid) :
Network::~Network()
{
char n[128];
if (_destroyed) {
char n[128];
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.conf",_id);
RR->node->dataStoreDelete(n);
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.mcerts",_id);
RR->node->dataStoreDelete(n);
} else {
clean();
_dumpMembershipCerts();
std::string buf("ZTMCD0");
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.mcerts",_id);
Mutex::Lock _l(_lock);
if ((!_config)||(_config.isPublic())||(_membershipCertificates.size() == 0)) {
RR->node->dataStoreDelete(n);
return;
}
for(std::map<Address,CertificateOfMembership>::iterator c(_membershipCertificates.begin());c!=_membershipCertificates.end();++c)
c->second.serialize2(buf);
RR->node->dataStorePut(n,buf,true);
}
}
@ -420,24 +433,4 @@ void Network::destroy()
_tap = (EthernetTap *)0;
}
void Network::_dumpMembershipCerts()
{
char n[128];
std::string buf("ZTMCD0");
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.mcerts",_id);
Mutex::Lock _l(_lock);
if ((!_config)||(_config.isPublic())||(_membershipCertificates.size() == 0)) {
RR->node->dataStoreDelete(n);
return;
}
for(std::map<Address,CertificateOfMembership>::iterator c(_membershipCertificates.begin());c!=_membershipCertificates.end();++c)
c->second.serialize2(buf);
RR->node->dataStorePut(n,buf,true);
}
} // namespace ZeroTier

View File

@ -335,16 +335,6 @@ public:
void destroy();
private:
void _dumpMembershipCerts();
inline void _mkNetworkFriendlyName(char *buf,unsigned int len)
{
// assumes _lock is locked
if (_config)
Utils::snprintf(buf,len,"ZeroTier One [%s]",_config->name().c_str());
else Utils::snprintf(buf,len,"ZeroTier One [%.16llx]",(unsigned long long)_id);
}
const RuntimeEnvironment *RR;
uint64_t _id;
MAC _mac; // local MAC address