mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Poll for network autoconf, and a few other documentation changes.
This commit is contained in:
parent
b9aeec9f29
commit
3368330b77
4 changed files with 40 additions and 13 deletions
|
@ -274,6 +274,24 @@ error_no_ZT_ARCH_defined;
|
||||||
*/
|
*/
|
||||||
#define ZT_PEER_DIRECT_PING_DELAY 120000
|
#define ZT_PEER_DIRECT_PING_DELAY 120000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay in ms between firewall opener packets to direct links
|
||||||
|
*
|
||||||
|
* This should be lower than the UDP conversation entry timeout in most
|
||||||
|
* stateful firewalls.
|
||||||
|
*/
|
||||||
|
#define ZT_FIREWALL_OPENER_DELAY 50000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay between requests for updated network autoconf information
|
||||||
|
*/
|
||||||
|
#define ZT_NETWORK_AUTOCONF_DELAY 120000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay in core loop between checks of network autoconf newness
|
||||||
|
*/
|
||||||
|
#define ZT_NETWORK_AUTOCONF_CHECK_DELAY 7000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimum delay in Node service loop
|
* Minimum delay in Node service loop
|
||||||
*
|
*
|
||||||
|
@ -288,14 +306,6 @@ error_no_ZT_ARCH_defined;
|
||||||
*/
|
*/
|
||||||
#define ZT_PEER_LINK_ACTIVITY_TIMEOUT ((ZT_PEER_DIRECT_PING_DELAY * 2) + 1000)
|
#define ZT_PEER_LINK_ACTIVITY_TIMEOUT ((ZT_PEER_DIRECT_PING_DELAY * 2) + 1000)
|
||||||
|
|
||||||
/**
|
|
||||||
* Delay in ms between firewall opener packets to direct links
|
|
||||||
*
|
|
||||||
* This should be lower than the UDP conversation entry timeout in most
|
|
||||||
* stateful firewalls.
|
|
||||||
*/
|
|
||||||
#define ZT_FIREWALL_OPENER_DELAY 50000
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IP hops (a.k.a. TTL) to set for firewall opener packets
|
* IP hops (a.k.a. TTL) to set for firewall opener packets
|
||||||
*
|
*
|
||||||
|
|
|
@ -406,6 +406,7 @@ Node::ReasonForTermination Node::run()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
uint64_t lastNetworkAutoconfCheck = 0;
|
||||||
uint64_t lastPingCheck = 0;
|
uint64_t lastPingCheck = 0;
|
||||||
uint64_t lastClean = Utils::now(); // don't need to do this immediately
|
uint64_t lastClean = Utils::now(); // don't need to do this immediately
|
||||||
uint64_t lastNetworkFingerprintCheck = 0;
|
uint64_t lastNetworkFingerprintCheck = 0;
|
||||||
|
@ -441,6 +442,17 @@ Node::ReasonForTermination Node::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request configuration for unconfigured nets, or nets with out of date
|
||||||
|
// configuration information.
|
||||||
|
if ((resynchronize)||((now - lastNetworkAutoconfCheck) >= ZT_NETWORK_AUTOCONF_CHECK_DELAY)) {
|
||||||
|
lastNetworkAutoconfCheck = now;
|
||||||
|
std::vector< SharedPtr<Network> > nets(_r->nc->networks());
|
||||||
|
for(std::vector< SharedPtr<Network> >::iterator n(nets.begin());n!=nets.end();++n) {
|
||||||
|
if ((now - (*n)->lastConfigUpdate()) >= ZT_NETWORK_AUTOCONF_DELAY)
|
||||||
|
(*n)->requestConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Periodically check for changes in our local multicast subscriptions and broadcast
|
// Periodically check for changes in our local multicast subscriptions and broadcast
|
||||||
// those changes to peers.
|
// those changes to peers.
|
||||||
if ((resynchronize)||((now - lastMulticastCheck) >= ZT_MULTICAST_LOCAL_POLL_PERIOD)) {
|
if ((resynchronize)||((now - lastMulticastCheck) >= ZT_MULTICAST_LOCAL_POLL_PERIOD)) {
|
||||||
|
@ -477,9 +489,9 @@ Node::ReasonForTermination Node::run()
|
||||||
lastPingCheck = now;
|
lastPingCheck = now;
|
||||||
try {
|
try {
|
||||||
if (_r->topology->amSupernode()) {
|
if (_r->topology->amSupernode()) {
|
||||||
// Supernodes are so super they don't even have to ping out. Everyone
|
// Supernodes are so super they don't even have to ping out, since
|
||||||
// comes to them! They're also never firewalled, so they don't
|
// all nodes ping them. They're also never firewalled so they
|
||||||
// send firewall openers.
|
// don't need firewall openers. They just ping each other.
|
||||||
std::vector< SharedPtr<Peer> > sns(_r->topology->supernodePeers());
|
std::vector< SharedPtr<Peer> > sns(_r->topology->supernodePeers());
|
||||||
for(std::vector< SharedPtr<Peer> >::const_iterator p(sns.begin());p!=sns.end();++p) {
|
for(std::vector< SharedPtr<Peer> >::const_iterator p(sns.begin());p!=sns.end();++p) {
|
||||||
if ((now - (*p)->lastDirectSend()) > ZT_PEER_DIRECT_PING_DELAY)
|
if ((now - (*p)->lastDirectSend()) > ZT_PEER_DIRECT_PING_DELAY)
|
||||||
|
@ -532,7 +544,7 @@ Node::ReasonForTermination Node::run()
|
||||||
unsigned long delay = std::min((unsigned long)ZT_MIN_SERVICE_LOOP_INTERVAL,_r->sw->doTimerTasks());
|
unsigned long delay = std::min((unsigned long)ZT_MIN_SERVICE_LOOP_INTERVAL,_r->sw->doTimerTasks());
|
||||||
uint64_t start = Utils::now();
|
uint64_t start = Utils::now();
|
||||||
_r->mainLoopWaitCondition.wait(delay);
|
_r->mainLoopWaitCondition.wait(delay);
|
||||||
lastDelayDelta = (long)(Utils::now() - start) - (long)delay;
|
lastDelayDelta = (long)(Utils::now() - start) - (long)delay; // used to detect sleep/wake
|
||||||
} catch (std::exception &exc) {
|
} catch (std::exception &exc) {
|
||||||
LOG("unexpected exception running Switch doTimerTasks: %s",exc.what());
|
LOG("unexpected exception running Switch doTimerTasks: %s",exc.what());
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
|
|
|
@ -43,6 +43,9 @@ namespace ZeroTier {
|
||||||
*
|
*
|
||||||
* Because this is introspective, it is safe to apply to a naked pointer
|
* Because this is introspective, it is safe to apply to a naked pointer
|
||||||
* multiple times provided there is always at least one holding SharedPtr.
|
* multiple times provided there is always at least one holding SharedPtr.
|
||||||
|
*
|
||||||
|
* Once C++11 is ubiquitous, this and a few other things like Thread might get
|
||||||
|
* torn out for their standard equivalents.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SharedPtr
|
class SharedPtr
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "NonCopyable.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
class RuntimeEnvironment;
|
class RuntimeEnvironment;
|
||||||
|
@ -37,7 +39,7 @@ class RuntimeEnvironment;
|
||||||
/**
|
/**
|
||||||
* Local system environment monitoring utilities
|
* Local system environment monitoring utilities
|
||||||
*/
|
*/
|
||||||
class SysEnv
|
class SysEnv : NonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SysEnv(const RuntimeEnvironment *renv);
|
SysEnv(const RuntimeEnvironment *renv);
|
||||||
|
|
Loading…
Add table
Reference in a new issue