From 82f27268b3800cf11cc7f53802a70ecd87d82f06 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 21 Jul 2022 13:36:37 +0200 Subject: global-functions: $IsTimeSync: cache a positive result The functions do not rely on perfectly synced time. About the right time is fine, that should make sure certificates are valid and mails are sent with reasonable headers. So cache the result if system is fine for later use. --- global-functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/global-functions b/global-functions index cfec740..8d44957 100644 --- a/global-functions +++ b/global-functions @@ -481,10 +481,17 @@ # check if system time is sync :set IsTimeSync do={ + :global IsTimeSyncCached; + :global LogPrintExit2; + :if ($IsTimeSyncCached = true) do={ + :return true; + } + :if ([ /system/ntp/client/get enabled ] = true) do={ :if ([ /system/ntp/client/get status ] = "synchronized") do={ + :set IsTimeSyncCached true; :return true; } :return false; @@ -492,6 +499,7 @@ :if ([ /ip/cloud/get update-time ] = true) do={ :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={ + :set IsTimeSyncCached true; :return true; } :return false; -- cgit v1.2.3-54-g00ecf