Update vendor/

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2020-05-14 19:47:23 +02:00
commit cdb9e7d2b8
No known key found for this signature in database
GPG key ID: C646B23C9E3245F1
527 changed files with 113006 additions and 150362 deletions

View file

@ -2,9 +2,8 @@ language: go
sudo: false
go:
- 1.7.x
- 1.8.x
- 1.9.x
- 1.12.x
- tip
matrix:

View file

@ -21,22 +21,23 @@ time, err := ntp.Time("0.beevik-ntp.pool.ntp.org")
## Querying time metadata
To obtain the current time as well as some additional metadata about the time,
use the `Query` function:
use the [`Query`](https://godoc.org/github.com/beevik/ntp#Query) function:
```go
response, err := ntp.Query("0.beevik-ntp.pool.ntp.org")
time := time.Now().Add(response.ClockOffset)
```
Alternatively, use the `QueryWithOptions` function if you want to change the
default behavior used by the `Query` function:
Alternatively, use the [`QueryWithOptions`](https://godoc.org/github.com/beevik/ntp#QueryWithOptions)
function if you want to change the default behavior used by the `Query`
function:
```go
options := ntp.QueryOptions{ Timeout: 30*time.Second, TTL: 5 }
response, err := ntp.QueryWithOptions("0.beevik-ntp.pool.ntp.org", options)
time := time.Now().Add(response.ClockOffset)
```
The `Response` structure returned by `Query` includes the following
information:
The [`Response`](https://godoc.org/github.com/beevik/ntp#Response) structure
returned by `Query` includes the following information:
* `Time`: The time the server transmitted its response, according to its own clock.
* `ClockOffset`: The estimated offset of the local system clock relative to the server's clock. For a more accurate time reading, you may add this offset to any subsequent system clock reading.
* `RTT`: An estimate of the round-trip-time delay between the client and the server.
@ -52,9 +53,9 @@ information:
* `KissCode`: A 4-character string describing the reason for a "kiss of death" response (stratum=0).
* `Poll`: The maximum polling interval between successive messages to the server.
The `Response` structure's `Validate` method performs additional sanity checks
to determine whether the response is suitable for time synchronization
purposes.
The `Response` structure's [`Validate`](https://godoc.org/github.com/beevik/ntp#Response.Validate)
method performs additional sanity checks to determine whether the response is
suitable for time synchronization purposes.
```go
err := response.Validate()
if err == nil {

View file

@ -1,3 +1,13 @@
Release v0.3.0
==============
There have been no breaking changes or further deprecations since the
previous release.
**Changes**
* Fixed a bug in the calculation of NTP timestamps.
Release v0.2.0
==============

28
vendor/github.com/beevik/ntp/ntp.go generated vendored
View file

@ -76,8 +76,12 @@ type ntpTime uint64
// and returns the corresponding time.Duration value.
func (t ntpTime) Duration() time.Duration {
sec := (t >> 32) * nanoPerSec
frac := (t & 0xffffffff) * nanoPerSec >> 32
return time.Duration(sec + frac)
frac := (t & 0xffffffff) * nanoPerSec
nsec := frac >> 32
if uint32(frac) >= 0x80000000 {
nsec++
}
return time.Duration(sec + nsec)
}
// Time interprets the fixed-point ntpTime as an absolute time and returns
@ -91,10 +95,11 @@ func (t ntpTime) Time() time.Time {
func toNtpTime(t time.Time) ntpTime {
nsec := uint64(t.Sub(ntpEpoch))
sec := nsec / nanoPerSec
// Round up the fractional component so that repeated conversions
// between time.Time and ntpTime do not yield continually decreasing
// results.
frac := (((nsec - sec*nanoPerSec) << 32) + nanoPerSec - 1) / nanoPerSec
nsec = uint64(nsec-sec*nanoPerSec) << 32
frac := uint64(nsec / nanoPerSec)
if nsec%nanoPerSec >= nanoPerSec/2 {
frac++
}
return ntpTime(sec<<32 | frac)
}
@ -105,10 +110,13 @@ type ntpTimeShort uint32
// Duration interprets the fixed-point ntpTimeShort as a number of elapsed
// seconds and returns the corresponding time.Duration value.
func (t ntpTimeShort) Duration() time.Duration {
t64 := uint64(t)
sec := (t64 >> 16) * nanoPerSec
frac := (t64 & 0xffff) * nanoPerSec >> 16
return time.Duration(sec + frac)
sec := uint64(t>>16) * nanoPerSec
frac := uint64(t&0xffff) * nanoPerSec
nsec := frac >> 16
if uint16(frac) >= 0x8000 {
nsec++
}
return time.Duration(sec + nsec)
}
// msg is an internal representation of an NTP packet.