Add beacon broadcasting back into Node.

This commit is contained in:
Adam Ierymenko 2015-04-14 18:20:03 -07:00
parent aeb4b42ab3
commit c9af603b9f
2 changed files with 11 additions and 0 deletions

View File

@ -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) {

View File

@ -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;