timesync

package
v0.0.0-...-13c5e55 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNTPServerHostnames = []string{

	"time.apple.com",
	"time.aws.com",
	"time.windows.com",
	"time.google.com",
	"time.cloudflare.com",
	"pool.ntp.org",
}
View Source
var DefaultNTPServerIPs = []string{

	"162.159.200.1",
	"162.159.200.123",
	"2606:4700:f1::1",
	"2606:4700:f1::123",
	"216.239.35.0",
	"216.239.35.4",
	"216.239.35.8",
	"216.239.35.12",
	"2001:4860:4806::",
	"2001:4860:4806:4::",
	"2001:4860:4806:8::",
	"2001:4860:4806:c::",
}

Functions

func RtcTimetoTime

func RtcTimetoTime(t unix.RTCTime) time.Time

func TimetoRtcTime

func TimetoRtcTime(t time.Time) unix.RTCTime

Types

type PreCheckFunc

type PreCheckFunc func() (bool, error)

type SyncMode

type SyncMode struct {
	Ntp             bool
	Http            bool
	Ordering        []string
	NtpUseFallback  bool
	HttpUseFallback bool
}

type TimeSync

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

func NewTimeSync

func NewTimeSync(opts *TimeSyncOptions) *TimeSync

func (*TimeSync) IsSyncSuccess

func (t *TimeSync) IsSyncSuccess() bool

IsSyncSuccess returns true if the system time is synchronized

func (*TimeSync) SetDhcpNtpAddresses

func (t *TimeSync) SetDhcpNtpAddresses(addresses []string)

func (*TimeSync) Start

func (t *TimeSync) Start()

Start starts the time sync

func (*TimeSync) Sync

func (t *TimeSync) Sync() error

Sync triggers a manual time sync

type TimeSyncOptions

type TimeSyncOptions struct {
	PreCheckFunc  PreCheckFunc
	PreCheckIPv4  PreCheckFunc
	PreCheckIPv6  PreCheckFunc
	Logger        *zerolog.Logger
	NetworkConfig *types.NetworkConfig
}

Jump to

Keyboard shortcuts

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