two/internal/hostsvc/clock_linux.go
GnomeZworc aa1cc58ae3
f-86: hostsvc: relais DNS et NTP par hôte, socket de contrôle #86
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
2026-10-25 20:32:06 +01:00

23 lines
458 B
Go

//go:build linux
package hostsvc
import (
"time"
"golang.org/x/sys/unix"
)
type SystemClock struct{}
func (SystemClock) Now() time.Time { return time.Now() }
func (SystemClock) Sync() (bool, time.Duration, error) {
var tx unix.Timex
state, err := unix.Adjtimex(&tx)
if err != nil {
return false, 0, err
}
synced := state != unix.TIME_ERROR && tx.Status&unix.STA_UNSYNC == 0
return synced, time.Duration(tx.Maxerror) * time.Microsecond, nil
}