mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
all: refactor router code to use interface
So the code is more modular, easier to read/maintain.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package ntp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Control-D-Inc/ctrld/internal/router/nvram"
|
||||
"tailscale.com/logtail/backoff"
|
||||
)
|
||||
|
||||
func Wait() error {
|
||||
// Wait until `ntp_ready=1` set.
|
||||
b := backoff.NewBackoff("ntp.Wait", func(format string, args ...any) {}, 10*time.Second)
|
||||
for {
|
||||
out, err := nvram.Run("get", "ntp_ready")
|
||||
if err != nil {
|
||||
return fmt.Errorf("PreStart: nvram: %w", err)
|
||||
}
|
||||
if out == "1" {
|
||||
return nil
|
||||
}
|
||||
b.BackOff(context.Background(), errors.New("ntp not ready"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user