diff --git a/node/Node.cpp b/node/Node.cpp index beb064303..6cdfc650b 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(beacon)) = RR->prng->next32(); + *(reinterpret_cast(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 957517061..cd8914e6a 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;