gotd: add time synchronization

This commit is contained in:
Tulir Asokan
2026-02-26 18:24:48 +02:00
parent 93fe3cb0ea
commit 6af986ded5
15 changed files with 110 additions and 48 deletions
+1 -8
View File
@@ -24,14 +24,7 @@ func (c *Conn) handleSessionCreated(b *bin.Buffer) error {
zap.Time("first_msg_time", created.Local()),
)
if (created.Before(now) && now.Sub(created) > maxPast) || created.Sub(now) > maxFuture {
c.log.Warn("Local clock needs synchronization",
zap.Time("first_msg_time", created),
zap.Time("local", now),
zap.Duration("time_difference", now.Sub(created)),
)
}
c.setServerTimeOffset(created.Sub(now))
c.storeSalt(s.ServerSalt)
if err := c.handler.OnSession(c.session()); err != nil {
return errors.Wrap(err, "handler.OnSession")