Documentation ¶
Overview ¶
Package timesync is used to check system time reliability by communicating with NTP time servers.
Index ¶
Constants ¶
View Source
const ( // MaxAllowedMessageDrift is the time we limit we receive and handle delivered messages within. MaxAllowedMessageDrift = 10 * time.Minute // NtpOffset is 70 years in seconds since ntp counts from 1900 and unix from 1970. NtpOffset = 2208988800 // DefaultNtpPort is the ntp protocol port. DefaultNtpPort = "123" )
Variables ¶
View Source
var (
DefaultServers = []string{
"0.pool.ntp.org",
"1.pool.ntp.org",
"time.google.com",
"time1.google.com",
"time.asia.apple.com",
"time.americas.apple.com",
}
)
DefaultServer is a list of relay on more than one server.
Functions ¶
func CheckMessageDrift ¶
CheckMessageDrift checks if a given message timestamp is too far from our local clock.
func CheckSystemClockDrift ¶
CheckSystemClockDrift is comparing our clock to the collected ntp data, and returns the drift and an error when drift reading failed or exceeds our preset MaxAllowedDrift
Types ¶
type NtpPacket ¶
type NtpPacket struct { Settings uint8 // leap yr indicator, ver number, and mode Stratum uint8 // stratum of local clock Poll int8 // poll exponent Precision int8 // precision exponent RootDelay uint32 // root delay RootDispersion uint32 // root dispersion ReferenceID uint32 // reference id RefTimeSec uint32 // reference timestamp sec RefTimeFrac uint32 // reference timestamp fractional OrigTimeSec uint32 // origin time secs OrigTimeFrac uint32 // origin time fractional RxTimeSec uint32 // receive time secs RxTimeFrac uint32 // receive time frac3 TxTimeSec uint32 // transmit time secs TxTimeFrac uint32 // transmit time frac }
NtpPacket is a 48 bytes packet used for querying ntp information.
Click to show internal directories.
Click to hide internal directories.