Documentation ¶
Overview ¶
Package nts provides a client implementation of Network Time Security (NTS) for the Network Time Protocol (NTP). It enables the secure querying of time-related information that can be used to synchronize the local system clock with a more accurate network clock. See RFC 8915 (https://tools.ietf.org/html/rfc8915) for more details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthFailedOnClient = errors.New("authentication failed on client") ErrAuthFailedOnServer = errors.New("authentication failed on server") ErrInvalidFormat = errors.New("invalid packet format") ErrNoCookies = errors.New("no NTS cookies available") ErrUniqueIDMismatch = errors.New("client and server unique ID mismatch") )
var ErrKeyExchangeFailed = errors.New("key exchange failure")
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session contains the state of an active NTS session. It is initialized by exchanging keys and cookies with an NTS key-exchange server, after which the connection to the key-exchange server is immediately dropped. The session's internal state is updated as NTP queries are made against an NTS-capable NTP server.
func NewSession ¶
NewSession creates an NTS session by connecting to an NTS key-exchange server and requesting keys and cookies to be used for future secure NTP queries. Once keys and cookies have been received, the connection is dropped. The address is of the form "host" or "host:port", where host is a domain name address. If no port is included, NTS default port 4460 is used.
func NewSessionWithOptions ¶ added in v0.1.1
func NewSessionWithOptions(address string, opt *SessionOptions) (*Session, error)
NewSessionWithOptions performs the same function as NewSession but allows for the customization of certain authentication behaviors.
func (*Session) Address ¶
Address returns the NTP server "host:port" pair configured for the session.
func (*Session) Query ¶
Query time data from the session's associated NTP server. The response contains information from which an accurate local time can be determined.
func (*Session) QueryWithOptions ¶
QueryWithOptions performs the same function as Query but allows for the customization of certain NTP behaviors.
type SessionOptions ¶ added in v0.1.1
type SessionOptions struct { // TLSConfig is used to override the default TLS configuration for NTS key // exchange. Attempts to downgrade the TLS protocol version below 1.3 // using this override are ignored. TLSConfig *tls.Config // Timeout determines how long the session waits for a response from the // key exchange server before failing with a timeout error. Defaults to 5 // seconds. Timeout time.Duration // Dialer is a callback that overrides the default TLS dialer behavior // used to establish a connection with the NTS key exchange endpoint's // network address. The tlsConfig is the TLS configuration used to // establish the connection. Dialer func(network, addr string, tlsConfig *tls.Config) (*tls.Conn, error) // Resolver is a callback used to override the NTP address returned by the // NTS key exchange protocol. The addr parameter contains the "host:port" // address of the NTP server returned by the key exchange protocol. The // function is expected to return a "host:port" address to override this // address. This option is commonly used in proxy setups. Resolver func(addr string) string }
SessionOptions contains options for customizing the behavior of an NTS session.