diff options
Diffstat (limited to 'node/Peer.cpp')
| -rw-r--r-- | node/Peer.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp index 0b981c8e..52727c78 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -156,8 +156,15 @@ void Peer::received( } } - if (!pathIsConfirmed) { - if ((verb == Packet::VERB_OK)||(RR->topology->amRoot())) { + if (pathIsConfirmed) { + +#ifdef ZT_ENABLE_CLUSTER + if ((RR->cluster)&&(verb == Packet::VERB_HELLO)) + RR->cluster->replicateHavePeer(_id); +#endif + + } else { + if (verb == Packet::VERB_OK) { Path *slot = (Path *)0; if (np < ZT_MAX_PEER_NETWORK_PATHS) { @@ -179,6 +186,11 @@ void Peer::received( _sortPaths(now); } +#ifdef ZT_ENABLE_CLUSTER + if (RR->cluster) + RR->cluster->replicateHavePeer(_id); +#endif + } else { /* If this path is not known, send a HELLO. We don't learn @@ -188,7 +200,7 @@ void Peer::received( if ((now - _lastPathConfirmationSent) >= ZT_MIN_PATH_CONFIRMATION_INTERVAL) { _lastPathConfirmationSent = now; TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),remoteAddr.toString().c_str()); - attemptToContactAt(RR,localAddr,remoteAddr,now); + sendHELLO(RR,localAddr,remoteAddr,now); } } @@ -196,11 +208,6 @@ void Peer::received( } } // end _lock -#ifdef ZT_ENABLE_CLUSTER - if ((RR->cluster)&&(pathIsConfirmed)) - RR->cluster->replicateHavePeer(_id,remoteAddr); -#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) @@ -208,7 +215,7 @@ void Peer::received( } } -void Peer::attemptToContactAt(const RuntimeEnvironment *RR,const InetAddress &localAddr,const InetAddress &atAddress,uint64_t now) +void Peer::sendHELLO(const RuntimeEnvironment *RR,const InetAddress &localAddr,const InetAddress &atAddress,uint64_t now) { // _lock not required here since _id is immutable and nothing else is accessed @@ -242,7 +249,7 @@ bool Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now,int inet if (p) { if ((now - p->lastReceived()) >= ZT_PEER_DIRECT_PING_DELAY) { //TRACE("PING %s(%s) after %llums/%llums send/receive inactivity",_id.address().toString().c_str(),p->address().toString().c_str(),now - p->lastSend(),now - p->lastReceived()); - attemptToContactAt(RR,p->localAddress(),p->address(),now); + sendHELLO(RR,p->localAddress(),p->address(),now); p->sent(now); } else if (((now - p->lastSend()) >= ZT_NAT_KEEPALIVE_DELAY)&&(!p->reliable())) { //TRACE("NAT keepalive %s(%s) after %llums/%llums send/receive inactivity",_id.address().toString().c_str(),p->address().toString().c_str(),now - p->lastSend(),now - p->lastReceived()); @@ -348,7 +355,7 @@ bool Peer::resetWithinScope(const RuntimeEnvironment *RR,InetAddress::IpScope sc unsigned int y = 0; while (x < np) { if (_paths[x].address().ipScope() == scope) { - attemptToContactAt(RR,_paths[x].localAddress(),_paths[x].address(),now); + sendHELLO(RR,_paths[x].localAddress(),_paths[x].address(),now); } else { _paths[y++] = _paths[x]; } |
