appc,ipn/ipnlocal: add a required event bus to the AppConnector type (#17390)

Require the presence of the bus, but do not use it yet.  Check for required
fields and update tests and production use to plumb the necessary arguments.

Updates #15160
Updates #17192

Change-Id: I8cefd2fdb314ca9945317d3320bd5ea6a92e8dcb
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
M. J. Fromberger
2025-10-01 12:00:32 -07:00
committed by GitHub
parent ce752b8a88
commit 67f1081269
5 changed files with 75 additions and 26 deletions
+1
View File
@@ -4804,6 +4804,7 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i
}
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: b.logf,
EventBus: b.sys.Bus.Get(),
RouteAdvertiser: b,
RouteInfo: ri,
StoreRoutesFunc: storeFunc,
+7 -3
View File
@@ -2307,15 +2307,17 @@ func TestDNSConfigForNetmapForExitNodeConfigs(t *testing.T) {
func TestOfferingAppConnector(t *testing.T) {
for _, shouldStore := range []bool{false, true} {
b := newTestBackend(t)
bus := b.sys.Bus.Get()
if b.OfferingAppConnector() {
t.Fatal("unexpected offering app connector")
}
rc := &appctest.RouteCollector{}
if shouldStore {
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: t.Logf, RouteInfo: &appc.RouteInfo{}, StoreRoutesFunc: fakeStoreRoutes,
Logf: t.Logf, EventBus: bus, RouteAdvertiser: rc, RouteInfo: &appc.RouteInfo{}, StoreRoutesFunc: fakeStoreRoutes,
})
} else {
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf})
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf, EventBus: bus, RouteAdvertiser: rc})
}
if !b.OfferingAppConnector() {
t.Fatal("unexpected not offering app connector")
@@ -2366,6 +2368,7 @@ func TestRouterAdvertiserIgnoresContainedRoutes(t *testing.T) {
func TestObserveDNSResponse(t *testing.T) {
for _, shouldStore := range []bool{false, true} {
b := newTestBackend(t)
bus := b.sys.Bus.Get()
// ensure no error when no app connector is configured
if err := b.ObserveDNSResponse(dnsResponse("example.com.", "192.0.0.8")); err != nil {
@@ -2376,12 +2379,13 @@ func TestObserveDNSResponse(t *testing.T) {
if shouldStore {
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
EventBus: bus,
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf, EventBus: bus, RouteAdvertiser: rc})
}
b.appConnector.UpdateDomains([]string{"example.com"})
b.appConnector.Wait(context.Background())
+10 -3
View File
@@ -259,12 +259,17 @@ func TestPeerAPIPrettyReplyCNAME(t *testing.T) {
if shouldStore {
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
EventBus: sys.Bus.Get(),
RouteAdvertiser: &appctest.RouteCollector{},
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: &appctest.RouteCollector{}})
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
EventBus: sys.Bus.Get(),
RouteAdvertiser: &appctest.RouteCollector{},
})
}
sys.Set(pm.Store())
sys.Set(eng)
@@ -339,12 +344,13 @@ func TestPeerAPIReplyToDNSQueriesAreObserved(t *testing.T) {
if shouldStore {
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
EventBus: sys.Bus.Get(),
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, EventBus: sys.Bus.Get(), RouteAdvertiser: rc})
}
sys.Set(pm.Store())
sys.Set(eng)
@@ -411,12 +417,13 @@ func TestPeerAPIReplyToDNSQueriesAreObservedWithCNAMEFlattening(t *testing.T) {
if shouldStore {
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
EventBus: sys.Bus.Get(),
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, EventBus: sys.Bus.Get(), RouteAdvertiser: rc})
}
sys.Set(pm.Store())
sys.Set(eng)