time

package
v2.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 11 Imported by: 13

Documentation

Index

Constants

View Source
const (

	// SetTimeOk means the time was set Correctly
	SetTimeOk = 1
	// TimedOut means there was no response from server
	TimedOut = 2
	// BadResponse means the response from server was not formatted correctly
	BadResponse = 3
	// InsaneResponse means the server provided a time value which is crazy
	InsaneResponse = 4
	// SycallFailed means the syscall failed to work to set the time
	SycallFailed = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {

	// The ServerName is also only required if the root ca chain
	// is not in the default list. This option should be omitted
	// if RootCA is not specified. It should match the common name
	// of the server's certificate.
	// ServerName string `yaml:"server_name"`
	// This option can be used in place of the RootCA and ServerName
	// for servers that are not signed by a well known certificate
	// authority. It will skip the authentication for the server. It
	// is not recommended outside of a test environment.
	NoValidate bool `yaml:"no_validate"`
	// This option turns off encryption entirely
	// it is only for testing
	NoTLS bool `yaml:"no_tls"`
	// Pretend true is run, but don't actually set the time
	Pretend bool `yaml:"pretend"`
	// This is the PEM encoded SSL client certificate. This is required
	// for all https based client connections. It provides the relay identity
	// to the server
	// ClientCertificate []byte
	// ClientCertificateString string `yaml:"client_cert"`
	// // This is the PEM encoded SSL client private key. This is required
	// // for all https based client connections.
	// ClientKey []byte
	// ClientKeyString string `yaml:"client_key"`
	// // This is the hostname or IP address of the relaymq server
	Host string `yaml:"host"`
	// This is the port of the relaymq server
	Port int `yaml:"port"`
	// CheckTimeInterval in seconds
	CheckTimeInterval int `yaml:"check_time_interval"`
}

ClientConfig for getting time. /time is tricky, b/c if the time is not sane on the system SSL validation can break. So, even if we are using SSL, we will get time value with validation disabled on SSL. We also do some sanity checks to make sure the time value makes sense.

type ClientError

type ClientError struct {
	StatusCode int
	Status     string
}

func (*ClientError) Error

func (err *ClientError) Error() string

type TimeClient

type TimeClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (ok bool, ret *TimeClient, err error)

NewClient creates a new TimeClient and validates the config

func (*TimeClient) Reconfigure

func (client *TimeClient) Reconfigure(config *ClientConfig) (err error)

Reconfigure allows you to reconfigure the client

func (*TimeClient) Run

func (client *TimeClient) Run()

Run starts the client

func (*TimeClient) StatusChannel

func (client *TimeClient) StatusChannel() (ok bool, status chan int)

StatusChannel returns the status channel which can be used to know if time is set if nothing reads the channel, the time will be set anyway, and a simple log message is printed out.

func (*TimeClient) Stop

func (client *TimeClient) Stop()

Stop the current client's worker

Jump to

Keyboard shortcuts

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