summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-05 12:34:54 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-05 12:34:54 -0400
commit3368330b777da9561539c04ea589aa7060e1d569 (patch)
treecd85bda86aa5347e773bc5386b8fa7ada6183c7d
parentb9aeec9f298415746f92da8444014093bb2a33c2 (diff)
downloadinfinitytier-3368330b777da9561539c04ea589aa7060e1d569.tar.gz
infinitytier-3368330b777da9561539c04ea589aa7060e1d569.zip
Poll for network autoconf, and a few other documentation changes.
-rw-r--r--node/Constants.hpp26
-rw-r--r--node/Node.cpp20
-rw-r--r--node/SharedPtr.hpp3
-rw-r--r--node/SysEnv.hpp4
4 files changed, 40 insertions, 13 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 36973b38..f1a36c65 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -275,6 +275,24 @@ error_no_ZT_ARCH_defined;
#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
*
* This is the shortest of the check delays/periods.
@@ -289,14 +307,6 @@ error_no_ZT_ARCH_defined;
#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
*
* 2 should permit traversal of double-NAT configurations, such as from inside
diff --git a/node/Node.cpp b/node/Node.cpp
index f42e1bad..ef2a801c 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -406,6 +406,7 @@ Node::ReasonForTermination Node::run()
#endif
try {
+ uint64_t lastNetworkAutoconfCheck = 0;
uint64_t lastPingCheck = 0;
uint64_t lastClean = Utils::now(); // don't need to do this immediately
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
// those changes to peers.
if ((resynchronize)||((now - lastMulticastCheck) >= ZT_MULTICAST_LOCAL_POLL_PERIOD)) {
@@ -477,9 +489,9 @@ Node::ReasonForTermination Node::run()
lastPingCheck = now;
try {
if (_r->topology->amSupernode()) {
- // Supernodes are so super they don't even have to ping out. Everyone
- // comes to them! They're also never firewalled, so they don't
- // send firewall openers.
+ // Supernodes are so super they don't even have to ping out, since
+ // all nodes ping them. They're also never firewalled so they
+ // don't need firewall openers. They just ping each other.
std::vector< SharedPtr<Peer> > sns(_r->topology->supernodePeers());
for(std::vector< SharedPtr<Peer> >::const_iterator p(sns.begin());p!=sns.end();++p) {
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());
uint64_t start = Utils::now();
_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) {
LOG("unexpected exception running Switch doTimerTasks: %s",exc.what());
} catch ( ... ) {
diff --git a/node/SharedPtr.hpp b/node/SharedPtr.hpp
index a31e135e..198804a4 100644
--- a/node/SharedPtr.hpp
+++ b/node/SharedPtr.hpp
@@ -43,6 +43,9 @@ namespace ZeroTier {
*
* Because this is introspective, it is safe to apply to a naked pointer
* 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>
class SharedPtr
diff --git a/node/SysEnv.hpp b/node/SysEnv.hpp
index af3efa5b..2db275c3 100644
--- a/node/SysEnv.hpp
+++ b/node/SysEnv.hpp
@@ -30,6 +30,8 @@
#include <stdint.h>
+#include "NonCopyable.hpp"
+
namespace ZeroTier {
class RuntimeEnvironment;
@@ -37,7 +39,7 @@ class RuntimeEnvironment;
/**
* Local system environment monitoring utilities
*/
-class SysEnv
+class SysEnv : NonCopyable
{
public:
SysEnv(const RuntimeEnvironment *renv);