summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node/Constants.hpp4
-rw-r--r--node/Switch.cpp16
2 files changed, 7 insertions, 13 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 901237ce..b7aa9817 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -253,10 +253,10 @@
/**
* How frequently to send a zero-byte UDP keepalive packet
*
- * There are NATs with timeouts as short as 30 seconds, so this turns out
+ * There are NATs with timeouts as short as 20 seconds, so this turns out
* to be needed.
*/
-#define ZT_NAT_KEEPALIVE_DELAY 25000
+#define ZT_NAT_KEEPALIVE_DELAY 19000
/**
* Delay between scans of the topology active peer DB for peers that need ping
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 247b2d18..989f497a 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -390,16 +390,10 @@ void Switch::rendezvous(const SharedPtr<Peer> &peer,const InetAddress &atAddr)
{
TRACE("sending NAT-t message to %s(%s)",peer->address().toString().c_str(),atAddr.toString().c_str());
const uint64_t now = RR->node->now();
-
- if ((atAddr.ss_family == AF_INET)&&(RR->sa->areGlobalIPv4PortsRandomized())) {
- peer->attemptToContactAt(RR,atAddr,now);
- } else {
- TRACE("behind randomizing symmetric NAT -- delaying initial message to %s(%s)",peer->address().toString().c_str(),atAddr.toString().c_str());
- }
-
+ peer->attemptToContactAt(RR,atAddr,now);
{
Mutex::Lock _l(_contactQueue_m);
- _contactQueue.push_back(ContactQueueEntry(peer,now + (ZT_NAT_T_TACTICAL_ESCALATION_DELAY / 2),atAddr));
+ _contactQueue.push_back(ContactQueueEntry(peer,now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY,atAddr));
}
}
@@ -454,12 +448,12 @@ unsigned long Switch::doTimerTasks(uint64_t now)
{
unsigned long nextDelay = 0xffffffff; // ceiling delay, caller will cap to minimum
- {
+ { // Iterate through NAT traversal strategies for entries in contact queue
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)) {
- // We've successfully NAT-t'd, so cancel attempt
+ if ((!qi->peer->alive(now))||(qi->peer->hasActiveDirectPath(now))) {
+ // Cancel attempt if we've already connected or peer is no longer "alive"
_contactQueue.erase(qi++);
continue;
} else {