diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-02-10 18:41:39 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-02-10 18:41:39 -0800 |
| commit | 0c951b6e56db47f2be4850343ae3908d0ea83099 (patch) | |
| tree | 08bc539fcbb90a4e5b3c0419495ea63c08a2d9fc /node/Switch.cpp | |
| parent | eadafd8de754336f8c06302305a26669762a365d (diff) | |
| download | infinitytier-0c951b6e56db47f2be4850343ae3908d0ea83099.tar.gz infinitytier-0c951b6e56db47f2be4850343ae3908d0ea83099.zip | |
More tweaks to new symmetric NAT buster, and stop using old iterative method since this supersedes it.
Diffstat (limited to 'node/Switch.cpp')
| -rw-r--r-- | node/Switch.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 1ed1dfe6..4e20300d 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -478,31 +478,31 @@ unsigned long Switch::doTimerTasks(uint64_t now) Mutex::Lock _l(_contactQueue_m); for(std::list<ContactQueueEntry>::iterator qi(_contactQueue.begin());qi!=_contactQueue.end();) { if (now >= qi->fireAtTime) { - if (qi->peer->hasActiveDirectPath(now)) { - // Cancel if connection has succeeded + if (!qi->peer->pushDirectPaths(qi->localAddr,qi->inaddr,now,true)) + qi->peer->sendHELLO(qi->localAddr,qi->inaddr,now); + _contactQueue.erase(qi++); + continue; + /* Old symmetric NAT buster code, obsoleted by port prediction alg in SelfAwareness but left around for now in case we revert + if (qi->strategyIteration == 0) { + // First strategy: send packet directly to destination + qi->peer->sendHELLO(qi->localAddr,qi->inaddr,now); + } else if (qi->strategyIteration <= 3) { + // Strategies 1-3: try escalating ports for symmetric NATs that remap sequentially + InetAddress tmpaddr(qi->inaddr); + int p = (int)qi->inaddr.port() + qi->strategyIteration; + if (p > 65535) + p -= 64511; + tmpaddr.setPort((unsigned int)p); + qi->peer->sendHELLO(qi->localAddr,tmpaddr,now); + } else { + // All strategies tried, expire entry _contactQueue.erase(qi++); continue; - } else { - if (qi->strategyIteration == 0) { - // First strategy: send packet directly to destination - qi->peer->sendHELLO(qi->localAddr,qi->inaddr,now); - } else if (qi->strategyIteration <= 3) { - // Strategies 1-3: try escalating ports for symmetric NATs that remap sequentially - InetAddress tmpaddr(qi->inaddr); - int p = (int)qi->inaddr.port() + qi->strategyIteration; - if (p > 65535) - p -= 64511; - tmpaddr.setPort((unsigned int)p); - qi->peer->sendHELLO(qi->localAddr,tmpaddr,now); - } else { - // All strategies tried, expire entry - _contactQueue.erase(qi++); - continue; - } - ++qi->strategyIteration; - qi->fireAtTime = now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY; - nextDelay = std::min(nextDelay,(unsigned long)ZT_NAT_T_TACTICAL_ESCALATION_DELAY); } + ++qi->strategyIteration; + qi->fireAtTime = now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY; + nextDelay = std::min(nextDelay,(unsigned long)ZT_NAT_T_TACTICAL_ESCALATION_DELAY); + */ } else { nextDelay = std::min(nextDelay,(unsigned long)(qi->fireAtTime - now)); } @@ -813,12 +813,13 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) relay = RR->topology->getBestRoot(); if (!(relay)||(!(viaPath = relay->getBestPath(now)))) - return false; // no paths, no root servers? + return false; // no paths, no root servers?, no relays? :P~~~ } if ((network)&&(relay)&&(network->isAllowed(peer))) { // Push hints for direct connectivity to this peer if we are relaying - peer->pushDirectPaths(viaPath,now,false); + peer->pushDirectPaths(viaPath->localAddress(),viaPath->address(),now,false); + viaPath->sent(now); } Packet tmp(packet); |
