diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-08 10:18:12 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-08 10:18:12 -0800 |
commit | 9c1a9f984b2bdffe94e147e3548080dfc7c2ef72 (patch) | |
tree | 47c8b4ec87b1cecda3faa4fd3becc5d6700f4672 /service/OneService.cpp | |
parent | 04c7adea07d3df6684f7776999150631226f19a5 (diff) | |
download | infinitytier-9c1a9f984b2bdffe94e147e3548080dfc7c2ef72.tar.gz infinitytier-9c1a9f984b2bdffe94e147e3548080dfc7c2ef72.zip |
Clean iddb.d periodically.
Diffstat (limited to 'service/OneService.cpp')
-rw-r--r-- | service/OneService.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index 7e8a58e8..b9ea32af 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -147,6 +147,9 @@ namespace ZeroTier { typedef BSDEthernetTap EthernetTap; } // How often to check for local interface addresses #define ZT_LOCAL_INTERFACE_CHECK_INTERVAL 60000 +// Clean files from iddb.d that are older than this (60 days) +#define ZT_IDDB_CLEANUP_AGE 5184000000ULL + namespace ZeroTier { namespace { @@ -826,6 +829,7 @@ public: uint64_t lastBindRefresh = 0; uint64_t lastUpdateCheck = clockShouldBe; uint64_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 + uint64_t lastCleanedIddb = 0; for(;;) { _run_m.lock(); if (!_run) { @@ -840,6 +844,12 @@ public: const uint64_t now = OSUtils::now(); + // Clean iddb.d on start and every 24 hours + if ((now - lastCleanedIddb) > 86400000) { + lastCleanedIddb = now; + OSUtils::cleanDirectory((_homePath + ZT_PATH_SEPARATOR_S "iddb.d").c_str(),now - ZT_IDDB_CLEANUP_AGE); + } + // Attempt to detect sleep/wake events by detecting delay overruns bool restarted = false; if ((now > clockShouldBe)&&((now - clockShouldBe) > 10000)) { |