dnsleapsecs

package module
Version: v0.0.0-...-b4171fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

README

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

View Source
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 Error

type Error struct {
	Code int
	Err  error
}

Error is the error type returned.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

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

func Decode(ip string) (Result, error)

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

func Fetch(ctx context.Context) (string, Result, error)

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

func Lookup(ctx context.Context, r Resolver) (string, Result, error)

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

func LookupHost(ctx context.Context, r Resolver, host string) (string, Result, error)

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.

Source Files

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL