summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-10-21 17:35:38 -0700
committerGrant Limberg <glimberg@gmail.com>2015-10-21 17:35:38 -0700
commit6471c1f4e26c0230b40bf0102a52493aa78236b9 (patch)
treeb8791931f4d4f6becbbab794f2a0d95d9363054d /node/Peer.cpp
parent21ae423feb0e63cdbdd47be921e257c1d59de27a (diff)
parenta46514b397acdf42451d41398ef77eec60744256 (diff)
downloadinfinitytier-6471c1f4e26c0230b40bf0102a52493aa78236b9.tar.gz
infinitytier-6471c1f4e26c0230b40bf0102a52493aa78236b9.zip
Merge branch 'adamierymenko-dev' into windows-ui
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 6f566be4..fa7b3aa4 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -34,6 +34,7 @@
#include "Network.hpp"
#include "AntiRecursion.hpp"
#include "SelfAwareness.hpp"
+#include "Cluster.hpp"
#include <algorithm>
@@ -81,6 +82,7 @@ void Peer::received(
{
const uint64_t now = RR->node->now();
bool needMulticastGroupAnnounce = false;
+ bool pathIsConfirmed = false;
{
Mutex::Lock _l(_lock);
@@ -88,8 +90,6 @@ void Peer::received(
_lastReceive = now;
if (!hops) {
- bool pathIsConfirmed = false;
-
/* Learn new paths from direct (hops == 0) packets */
{
unsigned int np = _numPaths;
@@ -107,7 +107,6 @@ void Peer::received(
// Learn paths if they've been confirmed via a HELLO or an ECHO
RemotePath *slot = (RemotePath *)0;
if (np < ZT_MAX_PEER_NETWORK_PATHS) {
- // Add new path
slot = &(_paths[np++]);
} else {
uint64_t slotLRmin = 0xffffffffffffffffULL;
@@ -154,6 +153,14 @@ void Peer::received(
_lastMulticastFrame = now;
}
+#ifdef ZT_ENABLE_CLUSTER
+ if ((pathIsConfirmed)&&(RR->cluster)) {
+ // Either shuttle this peer off somewhere else or report to other members that we have it
+ if (!RR->cluster->redirectPeer(_id.address(),remoteAddr,false))
+ RR->cluster->replicateHavePeer(_id);
+ }
+#endif
+
if (needMulticastGroupAnnounce) {
const std::vector< SharedPtr<Network> > networks(RR->node->allNetworks());
for(std::vector< SharedPtr<Network> >::const_iterator n(networks.begin());n!=networks.end();++n)
@@ -213,6 +220,12 @@ bool Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now,int inet
void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_t now,bool force)
{
+#ifdef ZT_ENABLE_CLUSTER
+ // Cluster mode disables normal PUSH_DIRECT_PATHS in favor of cluster-based peer redirection
+ if (RR->cluster)
+ return;
+#endif
+
Mutex::Lock _l(_lock);
if (((now - _lastDirectPathPushSent) >= ZT_DIRECT_PATH_PUSH_INTERVAL)||(force)) {