mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-14 03:31:22 +00:00
wgengine{,/monitor}: restore Engine.LinkChange, add Mon.InjectEvent
The Engine.LinkChange method was recently removed in
e3df29d488 while misremembering how
Android's link state mechanism worked.
Rather than do some last minute rearchitecting of link state on
Android before Tailscale 1.6, restore the old Engine.LinkChange hook
for now so the Android client doesn't need any changes. But change how
it's implemented to instead inject an event into the link monitor.
Fixes #1427
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
10f48087f4
commit
ffa70a617d
@@ -7,6 +7,7 @@ package monitor
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"tailscale.com/net/interfaces"
|
||||
)
|
||||
@@ -32,6 +33,29 @@ func TestMonitorJustClose(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMonitorInjectEvent(t *testing.T) {
|
||||
mon, err := New(t.Logf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer mon.Close()
|
||||
got := make(chan bool, 1)
|
||||
mon.RegisterChangeCallback(func(changed bool, state *interfaces.State) {
|
||||
select {
|
||||
case got <- true:
|
||||
default:
|
||||
}
|
||||
})
|
||||
mon.Start()
|
||||
mon.InjectEvent()
|
||||
select {
|
||||
case <-got:
|
||||
// Pass.
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timeout waiting for callback")
|
||||
}
|
||||
}
|
||||
|
||||
var monitor = flag.String("monitor", "", `go into monitor mode like 'route monitor'; test never terminates. Value can be either "raw" or "callback"`)
|
||||
|
||||
func TestMonitorMode(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user