Documentation ¶
Overview ¶
Package dnsleapsecs provides functionality for quering leap-seconds via DNS using an IPv4 encoding.
See for more information: http://phk.freebsd.dk/time/20151122/ For reference and manual checks search for "IERS Bulletin C" (leap second announcements).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TestVectors = []struct { IP string Result Result Err *Error }{ {"240.3.9.77", Result{1971, 12, 9, +1}, nil}, {"240.15.10.108", Result{1972, 6, 10, +1}, nil}, {"242.18.28.160", Result{1993, 12, 28, 0}, nil}, {"255.76.200.237", Result{2135, 1, 72, -1}, nil}, {"127.240.133.76", Result{0, 0, 0, 0}, &Error{Code: -1}}, {"255.209.76.40", Result{0, 0, 0, 0}, &Error{Code: -2}}, {"241.179.152.73", Result{0, 0, 0, 0}, &Error{Code: -3}}, }
TestVectors is test data to validate the decode logic.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver interface {
LookupHost(ctx context.Context, host string) (addrs []string, err error)
}
Resolver resolves DNS host records.
type Result ¶
type Result struct {
// Announced horizon.
Year, Month int
// DTAI is what to subtract from TAI to get UTC until that month ends.
DTAI int // dTAI
// Delta is what needs to be applied to DTAI at the end of that month.
Delta int
}
Result contains leap-second information.
func Decode ¶
Decode decodes leap-second information in a numeric IPv4 string ("253.253.100.11").
year and month is the announced horizon. dtai is what you subtract from TAI to get UTC until that month ends. delta is what you do to dtai at the end of that month.
func Fetch ¶
Fetch fetches and decodes leap-second information, using net.DefaultResolver and "leapsecond.utcd.org". Additionally the raw IPv4 address is returned as well.
In the unlikely case there is more than a single result, first successfully parsed address is used.
func Lookup ¶
Lookup fetches and parses the leap-second information, using the "leapsecond.utcd.org" host record. Additionally the raw IPv4 address is returned as well.
In the unlikely case there is more than a single result, first successfully parsed address is used.
func LookupHost ¶
LookupHost fetches and parses the leap-second information. Additionally the raw IPv4 address is returned as well.
In the unlikely case there is more than a single result, first successfully parsed address is used.