wgengine/monitor: start moving interface state accessor into monitor

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-03-01 07:55:30 -08:00
parent 14dc790137
commit 34188d93d4
2 changed files with 16 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import (
"sync"
"time"
"tailscale.com/net/interfaces"
"tailscale.com/types/logger"
)
@@ -72,6 +73,16 @@ func New(logf logger.Logf) (*Mon, error) {
}, nil
}
// InterfaceState returns the state of the machine's network interfaces,
// without any Tailscale ones.
func (m *Mon) InterfaceState() (*interfaces.State, error) {
s, err := interfaces.GetState()
if s != nil {
s.RemoveTailscaleInterfaces()
}
return s, err
}
// RegisterChangeCallback adds callback to the set of parties to be
// notified (in their own goroutine) when the network state changes.
// To remove this callback, call unregister (or close the monitor).