gotd / td

Telegram client, in Go. (MTProto API)
MIT License
1.51k stars 135 forks source link

clock: support network clock #883

Open iyear opened 2 years ago

iyear commented 2 years ago

Description

I want to add a basic network clock implementation that uses ntp to calibrate the time and record the offset, the Ticker and Timer implementations are the same as clock.System.

Note: will import new mod: https://github.com/beevik/ntp

Add it in gotd/td or in gotd/contrib?

References

https://core.telegram.org/mtproto#time-synchronization

Having received such a message or a container holding it, the client first performs a time synchronization (in effect, simply storing the difference between the server's time and its own to be able to compute the “correct” time in the future) and then verifies that the message identifiers for correctness.

ernado commented 2 years ago

Actually, Time can be calibrated from mtproto server, so no ntp server is required.

I think that ntp-based solution should be in contrib, and mtproto-based can be in main repo.