summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 13:27:52 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-27 13:27:52 -0800
commit64774d0d4f552b2864abd969c6bc69c0ced3b2e1 (patch)
tree4bf3409fb359c6b0703e5c8ef7f54d8b0a601905 /node/Peer.cpp
parentb88f5737337a978e9d610f6f24e8cd35078b184a (diff)
downloadinfinitytier-64774d0d4f552b2864abd969c6bc69c0ced3b2e1.tar.gz
infinitytier-64774d0d4f552b2864abd969c6bc69c0ced3b2e1.zip
Replace piecemeal designation of upstreams with the concept of moons, which is simpler and easier to use and inherits all the cool live update stuff of worlds (now called planets) and global roots.
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 2ef139e1..40356034 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -37,9 +37,6 @@
namespace ZeroTier {
-// Used to send varying values for NAT keepalive
-static uint32_t _natKeepaliveBuf = 0;
-
Peer::Peer(const RuntimeEnvironment *renv,const Identity &myIdentity,const Identity &peerIdentity) :
_lastReceive(0),
_lastNontrivialReceive(0),
@@ -355,8 +352,8 @@ void Peer::sendHELLO(const InetAddress &localAddr,const InetAddress &atAddress,u
outp.append(now);
RR->identity.serialize(outp,false);
atAddress.serialize(outp);
- outp.append((uint64_t)RR->topology->worldId());
- outp.append((uint64_t)RR->topology->worldTimestamp());
+ outp.append((uint64_t)RR->topology->planetWorldId());
+ outp.append((uint64_t)RR->topology->planetWorldTimestamp());
RR->node->expectReplyTo(outp.packetId());
outp.armor(_key,false); // HELLO is sent in the clear
RR->node->putPacket(localAddr,atAddress,outp.data(),outp.size());
@@ -401,12 +398,9 @@ bool Peer::doPingAndKeepalive(uint64_t now,int inetAddressFamily)
}
if (bestp >= 0) {
- if ((now - _paths[bestp].lastReceive) >= ZT_PEER_PING_PERIOD) {
+ if ( ((now - _paths[bestp].lastReceive) >= ZT_PEER_PING_PERIOD) || (_paths[bestp].path->needsHeartbeat(now)) ) {
attemptToContactAt(_paths[bestp].path->localAddress(),_paths[bestp].path->address(),now);
_paths[bestp].path->sent(now);
- } else if (_paths[bestp].path->needsHeartbeat(now)) {
- _natKeepaliveBuf += (uint32_t)((now * 0x9e3779b1) >> 1); // tumble this around to send constantly varying (meaningless) payloads
- _paths[bestp].path->send(RR,&_natKeepaliveBuf,sizeof(_natKeepaliveBuf),now);
}
return true;
} else {