net/sockstats: remove explicit dependency on wgengine/monitor

Followup to #7177 to avoid adding extra dependencies to the CLI. We
instead declare an interface for the link monitor.

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita
2023-03-03 08:37:14 -08:00
committed by GitHub
parent 7b73c9628d
commit 3e71e0ef68
7 changed files with 22 additions and 20 deletions
+9 -2
View File
@@ -11,7 +11,7 @@ package sockstats
import (
"context"
"tailscale.com/wgengine/monitor"
"tailscale.com/net/interfaces"
)
type SockStats struct {
@@ -34,6 +34,13 @@ func Get() *SockStats {
return get()
}
func SetLinkMonitor(lm *monitor.Mon) {
// LinkMonitor is the interface for the parts of wgengine/mointor's Mon that we
// need, to avoid the dependency.
type LinkMonitor interface {
InterfaceState() *interfaces.State
RegisterChangeCallback(interfaces.ChangeFunc) (unregister func())
}
func SetLinkMonitor(lm LinkMonitor) {
setLinkMonitor(lm)
}