1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

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.
This commit is contained in:
Christian Hesse
2022-07-21 13:36:37 +02:00
parent 329e606b93
commit 82f27268b3

View File

@ -481,10 +481,17 @@
# check if system time is sync # check if system time is sync
:set IsTimeSync do={ :set IsTimeSync do={
:global IsTimeSyncCached;
:global LogPrintExit2; :global LogPrintExit2;
:if ($IsTimeSyncCached = true) do={
:return true;
}
:if ([ /system/ntp/client/get enabled ] = true) do={ :if ([ /system/ntp/client/get enabled ] = true) do={
:if ([ /system/ntp/client/get status ] = "synchronized") do={ :if ([ /system/ntp/client/get status ] = "synchronized") do={
:set IsTimeSyncCached true;
:return true; :return true;
} }
:return false; :return false;
@ -492,6 +499,7 @@
:if ([ /ip/cloud/get update-time ] = true) do={ :if ([ /ip/cloud/get update-time ] = true) do={
:if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={ :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
:set IsTimeSyncCached true;
:return true; :return true;
} }
:return false; :return false;