diff options
Diffstat (limited to 'node')
-rw-r--r-- | node/Constants.hpp | 6 | ||||
-rw-r--r-- | node/Node.cpp | 10 | ||||
-rw-r--r-- | node/Path.hpp | 8 | ||||
-rw-r--r-- | node/Topology.hpp | 16 |
4 files changed, 22 insertions, 18 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp index 9e80a3e3..4bb85ebf 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -267,13 +267,13 @@ error_no_byte_order_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 +#define ZT_FIREWALL_OPENER_DELAY 30000 /** * Delay between requests for updated network autoconf information @@ -290,7 +290,7 @@ error_no_byte_order_defined; * * This is the shortest of the check delays/periods. */ -#define ZT_MIN_SERVICE_LOOP_INTERVAL ZT_NETWORK_FINGERPRINT_CHECK_DELAY +#define ZT_MIN_SERVICE_LOOP_INTERVAL 5000 /** * Activity timeout for links diff --git a/node/Node.cpp b/node/Node.cpp index bc01378d..b87195b1 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -598,12 +598,12 @@ Node::ReasonForTermination Node::run() } if (resynchronize) { - /* If resynchronizing, forget P2P links to all peers and then send - * something to formerly active ones. This will relay via a supernode - * which will trigger a new RENDEZVOUS and a new hole punch. This - * functor excludes supernodes, which are pinged separately above. */ - _r->topology->eachPeer(Topology::ResetActivePeers(_r,now)); + /* Send NOP to all peers on resynchronize, directly to supernodes and + * indirectly to regular nodes (to trigger RENDEZVOUS). Also clear + * learned paths since they're likely no longer valid, and close + * TCP sockets since they're also likely invalid. */ _r->sm->closeTcpSockets(); + _r->topology->eachPeer(Topology::ResetActivePeers(_r,now)); } else { /* Periodically check for changes in our local multicast subscriptions * and broadcast those changes to directly connected peers. */ diff --git a/node/Path.hpp b/node/Path.hpp index 639ddb9b..e1900bbb 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -133,10 +133,10 @@ public: Utils::snprintf(tmp,sizeof(tmp),"%s;%s;%lld;%lld;%lld;%lld;%s", t, _addr.toString().c_str(), - (long long)((_lastSend != 0) ? (now - _lastSend) : -1), - (long long)((_lastReceived != 0) ? (now - _lastReceived) : -1), - (long long)((_lastFirewallOpener != 0) ? (now - _lastFirewallOpener) : -1), - (long long)((_lastPing != 0) ? (now - _lastPing) : -1), + (long long)((_lastSend != 0) ? ((now - _lastSend) / 1000LL) : -1), + (long long)((_lastReceived != 0) ? ((now - _lastReceived) / 1000LL) : -1), + (long long)((_lastFirewallOpener != 0) ? ((now - _lastFirewallOpener) / 1000LL) : -1), + (long long)((_lastPing != 0) ? ((now - _lastPing) / 1000LL) : -1), ((_fixed) ? "fixed" : (active(now) ? "active" : "inactive")) ); return std::string(tmp); diff --git a/node/Topology.hpp b/node/Topology.hpp index 34b3f1bf..792b2fa7 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -272,8 +272,6 @@ public: /** * Function object to forget direct links to active peers and then ping them indirectly - * - * Note that this excludes supernodes. */ class ResetActivePeers { @@ -286,12 +284,18 @@ public: inline void operator()(Topology &t,const SharedPtr<Peer> &p) { - if (!_supernodeAddresses.count(p->address())) { - p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes + p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes + + Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP); + outp.armor(p->key(),false); // no need to encrypt a NOP + + if (_supernodeAddresses.count(p->address())) { + // Send NOP directly to supernodes + p->send(_r,outp.data(),outp.size(),_now); + } else { + // Send NOP indirectly to regular peers if still active, triggering a new RENDEZVOUS if (((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT)&&(_supernode)) { TRACE("sending reset NOP to %s",p->address().toString().c_str()); - Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP); - outp.armor(p->key(),false); // no need to encrypt a NOP _supernode->send(_r,outp.data(),outp.size(),_now); } } |