diff options
Diffstat (limited to 'node/Node.cpp')
-rw-r--r-- | node/Node.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 30c722b2..3342e6ca 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -76,6 +76,7 @@ Node::Node(void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,int64 memset(_expectingRepliesToBucketPtr,0,sizeof(_expectingRepliesToBucketPtr)); memset(_expectingRepliesTo,0,sizeof(_expectingRepliesTo)); memset(_lastIdentityVerification,0,sizeof(_lastIdentityVerification)); + memset((void *)(&_stats),0,sizeof(_stats)); uint64_t idtmp[2]; idtmp[0] = 0; idtmp[1] = 0; @@ -268,6 +269,15 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,int64_t now,volatile int64 Hashtable< Address,std::vector<InetAddress> > alwaysContact; RR->topology->getUpstreamsToContact(alwaysContact); + // Uncomment to dump stats + /* + for(unsigned int i=0;i<32;i++) { + if (_stats.inVerbCounts[i] > 0) + printf("%.2x\t%12lld %lld\n",i,(unsigned long long)_stats.inVerbCounts[i],(unsigned long long)_stats.inVerbBytes[i]); + } + printf("\n"); + */ + // Check last receive time on designated upstreams to see if we seem to be online int64_t lastReceivedFromUpstream = 0; { @@ -281,6 +291,19 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,int64_t now,volatile int64 } } + // Clean up any old local controller auth memorizations. + { + _localControllerAuthorizations_m.lock(); + Hashtable< _LocalControllerAuth,int64_t >::Iterator i(_localControllerAuthorizations); + _LocalControllerAuth *k = (_LocalControllerAuth *)0; + int64_t *v = (int64_t *)0; + while (i.next(k,v)) { + if ((*v - now) > (ZT_NETWORK_AUTOCONF_DELAY * 3)) + _localControllerAuthorizations.erase(*k); + } + _localControllerAuthorizations_m.unlock(); + } + // Get peers we should stay connected to according to network configs // Also get networks and whether they need config so we only have to do one pass over networks std::vector< std::pair< SharedPtr<Network>,bool > > networkConfigNeeded; @@ -633,6 +656,10 @@ std::vector<World> Node::moons() const void Node::ncSendConfig(uint64_t nwid,uint64_t requestPacketId,const Address &destination,const NetworkConfig &nc,bool sendLegacyFormatConfig) { + _localControllerAuthorizations_m.lock(); + _localControllerAuthorizations[_LocalControllerAuth(nwid,destination)] = now(); + _localControllerAuthorizations_m.unlock(); + if (destination == RR->identity.address()) { SharedPtr<Network> n(network(nwid)); if (!n) return; |