summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-07-06 12:33:00 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-07-06 12:33:00 -0700
commitdff8c02cfee9eaafae0974f3b070ff849a94c4ac (patch)
tree863e7aa4cb1174c2cb5ccc78cbe05d36cc20a902 /node/Peer.cpp
parent640ad577d1f52140adbe42e87b2da931bf15f430 (diff)
downloadinfinitytier-dff8c02cfee9eaafae0974f3b070ff849a94c4ac.tar.gz
infinitytier-dff8c02cfee9eaafae0974f3b070ff849a94c4ac.zip
Pull out and deprecate old cluster code. New cluster code will not be merged yet.
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index fb9a72b1..e16540b3 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -170,11 +170,11 @@ void Peer::received(
Mutex::Lock _l(_paths_m);
_PeerPath *potentialNewPeerPath = (_PeerPath *)0;
if (path->address().ss_family == AF_INET) {
- if ( (!_v4Path.p) || (!_v4Path.p->alive(now)) || (path->preferenceRank() >= _v4Path.p->preferenceRank()) ) {
+ if ( ( (!_v4Path.p) || (!_v4Path.p->alive(now)) || (path->preferenceRank() >= _v4Path.p->preferenceRank()) ) && ( (now - _v4Path.sticky) > ZT_PEER_PATH_EXPIRATION ) ) {
potentialNewPeerPath = &_v4Path;
}
} else if (path->address().ss_family == AF_INET6) {
- if ( (!_v6Path.p) || (!_v6Path.p->alive(now)) || (path->preferenceRank() >= _v6Path.p->preferenceRank()) ) {
+ if ( ( (!_v6Path.p) || (!_v6Path.p->alive(now)) || (path->preferenceRank() >= _v6Path.p->preferenceRank()) ) && ( (now - _v6Path.sticky) > ZT_PEER_PATH_EXPIRATION ) ) {
potentialNewPeerPath = &_v6Path;
}
}
@@ -422,4 +422,18 @@ bool Peer::doPingAndKeepalive(void *tPtr,uint64_t now,int inetAddressFamily)
return false;
}
+void Peer::redirect(void *tPtr,const int64_t localSocket,const InetAddress &remoteAddress,const uint64_t now)
+{
+ Mutex::Lock _l(_paths_m);
+ SharedPtr<Path> p(RR->topology->getPath(localSocket,remoteAddress));
+ attemptToContactAt(tPtr,localSocket,remoteAddress,now,true,p->nextOutgoingCounter());
+ if (remoteAddress.ss_family == AF_INET) {
+ _v4Path.p = p;
+ _v4Path.sticky = now;
+ } else if (remoteAddress.ss_family == AF_INET6) {
+ _v6Path.p = p;
+ _v6Path.sticky = now;
+ }
+}
+
} // namespace ZeroTier