Call clean on all networks periodically, generalize Topology clean cycle to an overall clean cycle.

This commit is contained in:
Adam Ierymenko 2013-07-30 11:14:53 -04:00
parent e4c5ad9f43
commit 7e156b2622
6 changed files with 40 additions and 9 deletions

View file

@ -34,6 +34,7 @@
#include "NodeConfig.hpp"
#include "Network.hpp"
#include "Switch.hpp"
#include "Packet.hpp"
namespace ZeroTier {
@ -103,6 +104,7 @@ Network::Network(const RuntimeEnvironment *renv,uint64_t id)
throw(std::runtime_error) :
_r(renv),
_tap(renv,renv->identity.address().toMAC(),ZT_IF_MTU,&_CBhandleTapData,this),
_lastConfigUpdate(0),
_id(id)
{
}
@ -114,16 +116,23 @@ Network::~Network()
void Network::setConfiguration(const Network::Config &conf)
{
Mutex::Lock _l(_lock);
_configuration = conf;
_myCertificate = conf.certificateOfMembership();
if ((conf.networkId() == _id)&&(conf.peerAddress() == _r->identity.address())) { // sanity check
_configuration = conf;
_myCertificate = conf.certificateOfMembership();
_lastConfigUpdate = Utils::now();
}
}
void Network::requestConfiguration()
{
Packet outp(controller(),_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
outp.append((uint64_t)_id);
_r->sw->send(outp,true);
}
bool Network::isAllowed(const Address &peer) const
{
// Exceptions can occur if we do not yet have *our* configuration.
try {
Mutex::Lock _l(_lock);
if (_configuration.isOpen())