summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-14 18:20:03 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-14 18:20:03 -0700
commitc9af603b9f6cf8fbc158ff00e776d97fb62e27a1 (patch)
tree61ba9a5c42883b245085a3c09ed713d68e6b0d56 /node
parentaeb4b42ab321a45901bb4dc01a25653cd8b6c79b (diff)
downloadinfinitytier-c9af603b9f6cf8fbc158ff00e776d97fb62e27a1.tar.gz
infinitytier-c9af603b9f6cf8fbc158ff00e776d97fb62e27a1.zip
Add beacon broadcasting back into Node.
Diffstat (limited to 'node')
-rw-r--r--node/Node.cpp10
-rw-r--r--node/Node.hpp1
2 files changed, 11 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index beb06430..6cdfc650 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -73,6 +73,7 @@ Node::Node(
_startTimeAfterInactivity(0),
_lastPingCheck(0),
_lastHousekeepingRun(0),
+ _lastBeacon(0),
_coreDesperation(0)
{
_newestVersionSeen[0] = ZEROTIER_ONE_VERSION_MAJOR;
@@ -252,6 +253,15 @@ ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,uint64_t *nextBackgroun
} catch ( ... ) {
return ZT1_RESULT_FATAL_ERROR_INTERNAL;
}
+
+ if ((now - _lastBeacon) >= ZT_BEACON_INTERVAL) {
+ _lastBeacon = now;
+ char beacon[13];
+ *(reinterpret_cast<uint32_t *>(beacon)) = RR->prng->next32();
+ *(reinterpret_cast<uint32_t *>(beacon + 4)) = RR->prng->next32();
+ RR->identity.address().copyTo(beacon + 8,5);
+ putPacket(ZT_DEFAULTS.v4Broadcast,beacon,13,0);
+ }
}
if ((now - _lastHousekeepingRun) >= ZT_HOUSEKEEPING_PERIOD) {
diff --git a/node/Node.hpp b/node/Node.hpp
index 95751706..cd8914e6 100644
--- a/node/Node.hpp
+++ b/node/Node.hpp
@@ -252,6 +252,7 @@ private:
uint64_t _startTimeAfterInactivity;
uint64_t _lastPingCheck;
uint64_t _lastHousekeepingRun;
+ uint64_t _lastBeacon;
unsigned int _coreDesperation;
unsigned int _newestVersionSeen[3]; // major, minor, revision
bool _online;