Skip to content

Commit 82f2726

Browse files
committed
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.
1 parent 329e606 commit 82f2726

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

global-functions

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,25 @@
481481

482482
# check if system time is sync
483483
:set IsTimeSync do={
484+
:global IsTimeSyncCached;
485+
484486
:global LogPrintExit2;
485487

488+
:if ($IsTimeSyncCached = true) do={
489+
:return true;
490+
}
491+
486492
:if ([ /system/ntp/client/get enabled ] = true) do={
487493
:if ([ /system/ntp/client/get status ] = "synchronized") do={
494+
:set IsTimeSyncCached true;
488495
:return true;
489496
}
490497
:return false;
491498
}
492499

493500
:if ([ /ip/cloud/get update-time ] = true) do={
494501
:if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
502+
:set IsTimeSyncCached true;
495503
:return true;
496504
}
497505
:return false;

0 commit comments

Comments
 (0)