From 48f05401ce35eb9b6ccf4c554c9a2757f9a5d242 Mon Sep 17 00:00:00 2001 From: dimitar10 <33422321+dimitar10@users.noreply.github.com> Date: Tue, 21 Jul 2020 13:42:41 +0200 Subject: [PATCH] Prevent server time from going backwards in UpdateTime (#64) --- crypto/time.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/time.go b/crypto/time.go index eeb91c9..85b0fff 100644 --- a/crypto/time.go +++ b/crypto/time.go @@ -7,8 +7,10 @@ import ( // UpdateTime updates cached time. func UpdateTime(newTime int64) { - pgp.latestServerTime = newTime - pgp.latestClientTime = time.Now() + if newTime > pgp.latestServerTime { + pgp.latestServerTime = newTime + pgp.latestClientTime = time.Now() + } } // GetUnixTime gets latest cached time.