Move linkstate boring change filtering to magicsock

So we can at least re-STUN on boring updates.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2020-03-10 12:25:42 -07:00
committed by Brad Fitzpatrick
parent 592fec7606
commit 023df9239e
3 changed files with 64 additions and 29 deletions

View File

@@ -7,14 +7,9 @@
package monitor
import (
"fmt"
"net"
"runtime"
"strings"
"sync"
"time"
"tailscale.com/net/interfaces"
"tailscale.com/types/logger"
)
@@ -104,7 +99,6 @@ func (m *Mon) Close() error {
// the change channel of changes, and stopping when a stop is issued.
func (m *Mon) pump() {
defer m.goroutines.Done()
last := interfaceSummary()
for {
_, err := m.om.Receive()
if err != nil {
@@ -118,14 +112,6 @@ func (m *Mon) pump() {
time.Sleep(time.Second)
continue
}
cur := interfaceSummary()
if cur == last {
continue
}
m.logf("wgengine/monitor: now %v (was %v)", cur, last)
last = cur
select {
case m.change <- struct{}{}:
case <-m.stop:
@@ -154,17 +140,3 @@ func (m *Mon) debounce() {
}
}
}
func interfaceSummary() string {
var sb strings.Builder
_ = interfaces.ForeachInterfaceAddress(func(ni interfaces.Interface, addr net.IP) {
if runtime.GOOS == "linux" && strings.HasPrefix(ni.Name, "tailscale") {
// Skip tailscale0, etc on Linux.
return
}
if ni.IsUp() {
fmt.Fprintf(&sb, "%s=%s ", ni.Name, addr)
}
})
return strings.TrimSpace(sb.String())
}