control/controlclient: introduce eventbus messages instead of callbacks (#16956)

This is a small introduction of the eventbus into controlclient that
communicates with mainly ipnlocal. While ipnlocal is a complicated part
of the codebase, the subscribers here are from the perspective of
ipnlocal already called async.

Updates #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2025-09-15 10:36:17 -04:00
committed by GitHub
parent 782c16c513
commit b816fd7117
15 changed files with 293 additions and 143 deletions

View File

@@ -35,6 +35,7 @@ import (
"tailscale.com/types/logger"
"tailscale.com/types/netmap"
"tailscale.com/types/persist"
"tailscale.com/util/eventbus/eventbustest"
)
func fieldsOf(t reflect.Type) (fields []string) {
@@ -218,6 +219,8 @@ func TestDirectProxyManual(t *testing.T) {
t.Skip("skipping without --live-network-test")
}
bus := eventbustest.NewBus(t)
dialer := &tsdial.Dialer{}
dialer.SetNetMon(netmon.NewStatic())
@@ -239,6 +242,7 @@ func TestDirectProxyManual(t *testing.T) {
},
Dialer: dialer,
ControlKnobs: &controlknobs.Knobs{},
Bus: bus,
}
d, err := NewDirect(opts)
if err != nil {
@@ -263,6 +267,8 @@ func TestHTTPSWithProxy(t *testing.T) { testHTTPS(t, true) }
func testHTTPS(t *testing.T, withProxy bool) {
bakedroots.ResetForTest(t, tlstest.TestRootCA())
bus := eventbustest.NewBus(t)
controlLn, err := tls.Listen("tcp", "127.0.0.1:0", tlstest.ControlPlane.ServerTLSConfig())
if err != nil {
t.Fatal(err)
@@ -327,6 +333,7 @@ func testHTTPS(t *testing.T, withProxy bool) {
t.Logf("PopBrowserURL: %q", url)
},
Dialer: dialer,
Bus: bus,
}
d, err := NewDirect(opts)
if err != nil {