Update vendored packages
This commit is contained in:
parent
84eaa8fecd
commit
ce117d7a40
119 changed files with 2565 additions and 1524 deletions
19
vendor/github.com/beevik/ntp/README.md
generated
vendored
19
vendor/github.com/beevik/ntp/README.md
generated
vendored
|
|
@ -4,12 +4,17 @@
|
|||
ntp
|
||||
===
|
||||
|
||||
The ntp package is a small implementation of a limited NTP client. It
|
||||
requests the current time from a remote NTP server according to
|
||||
selected version of the NTP protocol. Client uses version 4 of the NTP
|
||||
protocol RFC5905 by default.
|
||||
The ntp package is an implementation of a simple NTP client. It allows you
|
||||
to connect to a remote NTP server and request the current time.
|
||||
|
||||
The approach was inspired by a post to the go-nuts mailing list by
|
||||
Michael Hofmann:
|
||||
To request the current time using version 4 of the NTP protocol, simply do the
|
||||
following:
|
||||
```go
|
||||
time, err := ntp.Time("0.pool.ntp.org")
|
||||
```
|
||||
|
||||
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/FlcdMU5fkLQ
|
||||
To request the current time along with additional metadata, use the Query
|
||||
function:
|
||||
```go
|
||||
response, err := ntp.Query("0.pool.ntp.org", 4)
|
||||
```
|
||||
|
|
|
|||
24
vendor/github.com/beevik/ntp/ntp.go
generated
vendored
24
vendor/github.com/beevik/ntp/ntp.go
generated
vendored
|
|
@ -3,9 +3,8 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package ntp provides a simple mechanism for querying the current time from
|
||||
// a remote NTP server. This package only supports NTP client mode behavior
|
||||
// and version 4 of the NTP protocol. See RFC 5905. Approach inspired by go-
|
||||
// nuts post by Michael Hofmann:
|
||||
// a remote NTP server. See RFC 5905. Approach inspired by go-nuts post by
|
||||
// Michael Hofmann:
|
||||
//
|
||||
// https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/FlcdMU5fkLQ
|
||||
package ntp
|
||||
|
|
@ -117,8 +116,10 @@ type Response struct {
|
|||
RootDispersion time.Duration // server's dispersion to the reference clock
|
||||
}
|
||||
|
||||
// Query returns information from the remote NTP server specifed as host. NTP
|
||||
// client mode is used.
|
||||
// Query returns the current time from the remote server host using the
|
||||
// requested version of the NTP protocol. It also returns additional
|
||||
// information about the exchanged time information. The version may be 2, 3,
|
||||
// or 4; although 4 is most typically used.
|
||||
func Query(host string, version int) (*Response, error) {
|
||||
m, err := getTime(host, version)
|
||||
now := toNtpTime(time.Now())
|
||||
|
|
@ -146,8 +147,7 @@ func Query(host string, version int) (*Response, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// Time returns the "receive time" from the remote NTP server specifed as
|
||||
// host. NTP client mode is used.
|
||||
// getTime returns the "receive time" from the remote NTP server host.
|
||||
func getTime(host string, version int) (*msg, error) {
|
||||
if version < 2 || version > 4 {
|
||||
panic("ntp: invalid version number")
|
||||
|
|
@ -183,9 +183,9 @@ func getTime(host string, version int) (*msg, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// TimeV returns the "receive time" from the remote NTP server specifed as
|
||||
// host. Use the NTP client mode with the requested version number (2, 3, or
|
||||
// 4).
|
||||
// TimeV returns the current time from the remote server host using the
|
||||
// requested version of the NTP protocol. The version may be 2, 3, or 4;
|
||||
// although 4 is most typically used.
|
||||
func TimeV(host string, version int) (time.Time, error) {
|
||||
m, err := getTime(host, version)
|
||||
if err != nil {
|
||||
|
|
@ -194,8 +194,8 @@ func TimeV(host string, version int) (time.Time, error) {
|
|||
return m.ReceiveTime.Time().Local(), nil
|
||||
}
|
||||
|
||||
// Time returns the "receive time" from the remote NTP server specifed as
|
||||
// host. NTP client mode version 4 is used.
|
||||
// Time returns the current time from the remote server host using version 4
|
||||
// of the NTP protocol.
|
||||
func Time(host string) (time.Time, error) {
|
||||
return TimeV(host, 4)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue