control/controlclient: replace a status func with Observer interface

For now the method has only one interface (the same as the func it's
replacing) but it will grow, eventually with the goal to remove the
controlclient.Status type for most purposes.

Updates #1909

Change-Id: I715c8bf95e3f5943055a94e76af98d988558a2f2
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-28 15:27:39 -07:00
committed by Brad Fitzpatrick
parent a64593d7ef
commit 55bb7314f2
5 changed files with 34 additions and 21 deletions
+9 -2
View File
@@ -101,6 +101,12 @@ type Direct struct {
lastPingURL string // last PingRequest.URL received, for dup suppression
}
// Observer is implemented by users of the control client (such as LocalBackend)
// to get notified of changes in the control client's status.
type Observer interface {
SetControlClientStatus(Status)
}
type Options struct {
Persist persist.Persist // initial persistent data
GetMachinePrivateKey func() (key.MachinePrivate, error) // returns the machine key to use
@@ -122,8 +128,9 @@ type Options struct {
Dialer *tsdial.Dialer // non-nil
C2NHandler http.Handler // or nil
// Status is called when there's a change in status.
Status func(Status)
// Observer is called when there's a change in status to report
// from the control client.
Observer Observer
// SkipIPForwardingCheck declares that the host's IP
// forwarding works and should not be double-checked by the