Documentation
¶
Index ¶
- Variables
- func GetBuiltinServers() []string
- func Now(address ...string) (time.Time, error)
- func RestartNTPService(ctx context.Context) error
- func SetSystemNTPServers(ctx context.Context, servers []string) error
- func UpdateSystemTime(ctx context.Context, t time.Time) error
- func UpdateSystemTimeZone(ctx context.Context, tz string) error
- type NTPServiceType
- type SystemNTPConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoAvailableServer = errors.New("no available NTP server found")
View Source
var ErrNotReachable = errors.New("failed to reach NTP server")
Functions ¶
func RestartNTPService ¶
RestartNTPService 重启 NTP 服务
func SetSystemNTPServers ¶
SetSystemNTPServers 设置系统 NTP 服务器
Types ¶
type NTPServiceType ¶
type NTPServiceType string
NTPServiceType 表示系统使用的 NTP 服务类型
const ( NTPServiceTimesyncd NTPServiceType = "timesyncd" // systemd-timesyncd (Debian/Ubuntu) NTPServiceChrony NTPServiceType = "chrony" // chrony (RHEL/CentOS/Rocky) NTPServiceUnknown NTPServiceType = "unknown" // 未知或不支持 )
func DetectNTPService ¶
func DetectNTPService(ctx context.Context) NTPServiceType
DetectNTPService 检测系统使用的 NTP 服务类型
type SystemNTPConfig ¶
type SystemNTPConfig struct {
ServiceType NTPServiceType `json:"service_type"` // 服务类型
Servers []string `json:"servers"` // NTP 服务器列表
}
SystemNTPConfig 系统 NTP 配置信息
func GetSystemNTPConfig ¶
func GetSystemNTPConfig(ctx context.Context) (*SystemNTPConfig, error)
GetSystemNTPConfig 获取系统 NTP 配置
Click to show internal directories.
Click to hide internal directories.