f-86: hostsvc: relais DNS et NTP par hôte, socket de contrôle #86
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
ae7213a9d1
commit
d4b83bdb17
20 changed files with 2235 additions and 0 deletions
23
internal/hostsvc/clock_linux.go
Normal file
23
internal/hostsvc/clock_linux.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue