summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-09 09:01:41 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-09 09:01:41 -0800
commit473ce82040e6f4eb54594baf07a6daed727d5f35 (patch)
tree26588d7ff6bd3d85717446a01c4b206fcb44914a /node/Switch.cpp
parentab013d831c0744fcc87ffca2834f9762803705dd (diff)
parent6bc8c9d8efd05c7f85ac269be29c781fcc40672b (diff)
downloadinfinitytier-473ce82040e6f4eb54594baf07a6daed727d5f35.tar.gz
infinitytier-473ce82040e6f4eb54594baf07a6daed727d5f35.zip
Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 8d3c12f5..355440a5 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -435,7 +435,7 @@ void Switch::rendezvous(const SharedPtr<Peer> &peer,const InetAddress &localAddr
{
TRACE("sending NAT-t message to %s(%s)",peer->address().toString().c_str(),atAddr.toString().c_str());
const uint64_t now = RR->node->now();
- peer->attemptToContactAt(RR,localAddr,atAddr,now);
+ peer->sendHELLO(RR,localAddr,atAddr,now);
{
Mutex::Lock _l(_contactQueue_m);
_contactQueue.push_back(ContactQueueEntry(peer,now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY,localAddr,atAddr));
@@ -508,14 +508,14 @@ unsigned long Switch::doTimerTasks(uint64_t now)
} else {
if (qi->strategyIteration == 0) {
// First strategy: send packet directly to destination
- qi->peer->attemptToContactAt(RR,qi->localAddr,qi->inaddr,now);
+ qi->peer->sendHELLO(RR,qi->localAddr,qi->inaddr,now);
} else if (qi->strategyIteration <= 4) {
// Strategies 1-4: try escalating ports for symmetric NATs that remap sequentially
InetAddress tmpaddr(qi->inaddr);
int p = (int)qi->inaddr.port() + qi->strategyIteration;
if (p < 0xffff) {
tmpaddr.setPort((unsigned int)p);
- qi->peer->attemptToContactAt(RR,qi->localAddr,tmpaddr,now);
+ qi->peer->sendHELLO(RR,qi->localAddr,tmpaddr,now);
} else qi->strategyIteration = 5;
} else {
// All strategies tried, expire entry
@@ -616,15 +616,15 @@ void Switch::_handleRemotePacketFragment(const InetAddress &localAddr,const Inet
if (fragment.hops() < ZT_RELAY_MAX_HOPS) {
fragment.incrementHops();
-#ifdef ZT_ENABLE_CLUSTER
- if ((RR->cluster)&&(RR->cluster->sendViaCluster(Address(),destination,fragment.data(),fragment.size(),false)))
- return;
-#endif
-
// Note: we don't bother initiating NAT-t for fragments, since heads will set that off.
// It wouldn't hurt anything, just redundant and unnecessary.
SharedPtr<Peer> relayTo = RR->topology->getPeer(destination);
if ((!relayTo)||(!relayTo->send(RR,fragment.data(),fragment.size(),RR->node->now()))) {
+#ifdef ZT_ENABLE_CLUSTER
+ if ((RR->cluster)&&(RR->cluster->sendViaCluster(Address(),destination,fragment.data(),fragment.size(),false)))
+ return;
+#endif
+
// Don't know peer or no direct path -- so relay via root server
relayTo = RR->topology->getBestRoot();
if (relayTo)
@@ -702,19 +702,6 @@ void Switch::_handleRemotePacketHead(const InetAddress &localAddr,const InetAddr
if (packet->hops() < ZT_RELAY_MAX_HOPS) {
packet->incrementHops();
-#ifdef ZT_ENABLE_CLUSTER
- if (RR->cluster) {
- Mutex::Lock _l(_lastUniteAttempt_m);
- uint64_t &luts = _lastUniteAttempt[_LastUniteKey(source,destination)];
- const bool shouldUnite = ((now - luts) >= ZT_MIN_UNITE_INTERVAL);
- if (RR->cluster->sendViaCluster(source,destination,packet->data(),packet->size(),shouldUnite)) {
- if (shouldUnite)
- luts = now;
- return;
- }
- }
-#endif
-
SharedPtr<Peer> relayTo = RR->topology->getPeer(destination);
if ((relayTo)&&((relayTo->send(RR,packet->data(),packet->size(),now)))) {
Mutex::Lock _l(_lastUniteAttempt_m);
@@ -724,6 +711,19 @@ void Switch::_handleRemotePacketHead(const InetAddress &localAddr,const InetAddr
unite(source,destination);
}
} else {
+#ifdef ZT_ENABLE_CLUSTER
+ if (RR->cluster) {
+ Mutex::Lock _l(_lastUniteAttempt_m);
+ uint64_t &luts = _lastUniteAttempt[_LastUniteKey(source,destination)];
+ const bool shouldUnite = ((now - luts) >= ZT_MIN_UNITE_INTERVAL);
+ if (RR->cluster->sendViaCluster(source,destination,packet->data(),packet->size(),shouldUnite)) {
+ if (shouldUnite)
+ luts = now;
+ return;
+ }
+ }
+#endif
+
relayTo = RR->topology->getBestRoot(&source,1,true);
if (relayTo)
relayTo->send(RR,packet->data(),packet->size(),now);