diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-10-25 16:08:14 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-10-25 16:08:14 -0700 |
commit | 2cc4dc5a6fb815f97614c71429d5c4674576ebef (patch) | |
tree | 45542149d0c94cf5a77cf69b42694864edf2bc86 /service | |
parent | fac7dc9c913a94550692c31ca6c24fa4db5b5b52 (diff) | |
download | infinitytier-2cc4dc5a6fb815f97614c71429d5c4674576ebef.tar.gz infinitytier-2cc4dc5a6fb815f97614c71429d5c4674576ebef.zip |
Clean peers.d periodically and delete peers older than 30 days.
Diffstat (limited to 'service')
-rw-r--r-- | service/OneService.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index 743f5a9a..e962fb5b 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -762,6 +762,7 @@ public: int64_t lastTapMulticastGroupCheck = 0; int64_t lastBindRefresh = 0; int64_t lastUpdateCheck = clockShouldBe; + int64_t lastCleanedPeersDb = 0; int64_t lastLocalInterfaceAddressCheck = (clockShouldBe - ZT_LOCAL_INTERFACE_CHECK_INTERVAL) + 15000; // do this in 15s to give portmapper time to configure and other things time to settle for(;;) { _run_m.lock(); @@ -856,6 +857,12 @@ public: _node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*i))); } + // Clean peers.d periodically + if ((now - lastCleanedPeersDb) >= 3600000) { + lastCleanedPeersDb = now; + OSUtils::cleanDirectory((_homePath + ZT_PATH_SEPARATOR_S "peers.d").c_str(),now - 2592000000LL); // delete older than 30 days + } + const unsigned long delay = (dl > now) ? (unsigned long)(dl - now) : 100; clockShouldBe = now + (uint64_t)delay; _phy.poll(delay); |