diff --git a/llarp/constants/time.hpp b/llarp/constants/time.hpp new file mode 100644 index 000000000..69866e2c8 --- /dev/null +++ b/llarp/constants/time.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace llarp +{ + using namespace std::literals; + /// how big of a time skip before we reset network state + constexpr auto TimeskipDetectedDuration = 1min; +} // namespace llarp diff --git a/llarp/context.cpp b/llarp/context.cpp index 59a54dc28..ecba8ee09 100644 --- a/llarp/context.cpp +++ b/llarp/context.cpp @@ -166,6 +166,14 @@ namespace llarp SigINT(); } #ifndef _WIN32 + if (sig == SIGUSR1) + { + if (router and not router->IsServiceNode()) + { + LogInfo("SIGUSR1: resetting network state"); + router->Thaw(); + } + } if (sig == SIGHUP) { Reload(); diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 2204e4766..835850e75 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -807,6 +808,12 @@ namespace llarp return; // LogDebug("tick router"); const auto now = Now(); + if (const auto delta = now - _lastTick; _lastTick != 0s and delta > TimeskipDetectedDuration) + { + // we detected a time skip into the futre, thaw the network + LogWarn("Timeskip of ", delta, " detected. Resetting network state"); + Thaw(); + } #if defined(WITH_SYSTEMD) {