summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-09-22 15:58:00 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-09-22 15:58:00 -0700
commitd656e87395441b995d376c9174f3f0570cbf4396 (patch)
treedafcbb64127b90233f94107ede0d8ed53f4f69d5 /node
parentddf3d1f94932738d058aa57ce2fa11f3c9bde089 (diff)
downloadinfinitytier-d656e87395441b995d376c9174f3f0570cbf4396.tar.gz
infinitytier-d656e87395441b995d376c9174f3f0570cbf4396.zip
Send a random small payload for NAT keepalives, since zero byte packets seem to fail to keep associations alive behind some NATs.
Diffstat (limited to 'node')
-rw-r--r--node/Peer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index c27afa8f..85874105 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -39,6 +39,9 @@
namespace ZeroTier {
+// Used to send varying values for NAT keepalive
+static uint32_t _natKeepaliveBuf = 0;
+
Peer::Peer(const Identity &myIdentity,const Identity &peerIdentity)
throw(std::runtime_error) :
_lastUsed(0),
@@ -217,8 +220,9 @@ void Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now)
attemptToContactAt(RR,bestPath->address(),now);
bestPath->sent(now);
} else if (((now - bestPath->lastSend()) >= ZT_NAT_KEEPALIVE_DELAY)&&(!bestPath->reliable())) {
+ _natKeepaliveBuf += (uint32_t)now * 2654435761; // tumble this around to send constantly varying (meaningless) payloads
TRACE("NAT keepalive %s(%s)",_id.address().toString().c_str(),bestPath->address().toString().c_str());
- RR->node->putPacket(bestPath->address(),"",0);
+ RR->node->putPacket(bestPath->address(),&_natKeepaliveBuf,sizeof(_natKeepaliveBuf));
bestPath->sent(now);
}
}