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:
@ -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;
|
||||
|
Reference in New Issue
Block a user