From 2cc4dc5a6fb815f97614c71429d5c4674576ebef Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 25 Oct 2017 16:08:14 -0700 Subject: Clean peers.d periodically and delete peers older than 30 days. --- service/OneService.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'service') 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(&(*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); -- cgit v1.2.3