appc: factor app connector arguments into a Config type (#17389)

Replace the positional arguments to NewAppConnector with a Config struct.
Update the existing uses. Other than the API change, there are no functional
changes in this commit.

Updates #15160
Updates #17192

Change-Id: Ibf37f021372155a4db8aaf738f4b4f2c746bf623
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
M. J. Fromberger
2025-10-01 11:39:01 -07:00
committed by GitHub
parent 05a4c8e839
commit 6f7ce5eb5d
5 changed files with 133 additions and 38 deletions

View File

@@ -4802,7 +4802,12 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i
}
storeFunc = b.storeRouteInfo
}
b.appConnector = appc.NewAppConnector(b.logf, b, ri, storeFunc)
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: b.logf,
RouteAdvertiser: b,
RouteInfo: ri,
StoreRoutesFunc: storeFunc,
})
}
if nm == nil {
return

View File

@@ -2309,9 +2309,11 @@ func TestOfferingAppConnector(t *testing.T) {
t.Fatal("unexpected offering app connector")
}
if shouldStore {
b.appConnector = appc.NewAppConnector(t.Logf, nil, &appc.RouteInfo{}, fakeStoreRoutes)
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: t.Logf, RouteInfo: &appc.RouteInfo{}, StoreRoutesFunc: fakeStoreRoutes,
})
} else {
b.appConnector = appc.NewAppConnector(t.Logf, nil, nil, nil)
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf})
}
if !b.OfferingAppConnector() {
t.Fatal("unexpected not offering app connector")
@@ -2370,9 +2372,14 @@ func TestObserveDNSResponse(t *testing.T) {
rc := &appctest.RouteCollector{}
if shouldStore {
b.appConnector = appc.NewAppConnector(t.Logf, rc, &appc.RouteInfo{}, fakeStoreRoutes)
b.appConnector = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
b.appConnector = appc.NewAppConnector(t.Logf, rc, nil, nil)
b.appConnector = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
}
b.appConnector.UpdateDomains([]string{"example.com"})
b.appConnector.Wait(context.Background())

View File

@@ -257,9 +257,14 @@ func TestPeerAPIPrettyReplyCNAME(t *testing.T) {
pm := must.Get(newProfileManager(new(mem.Store), t.Logf, ht))
var a *appc.AppConnector
if shouldStore {
a = appc.NewAppConnector(t.Logf, &appctest.RouteCollector{}, &appc.RouteInfo{}, fakeStoreRoutes)
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
RouteAdvertiser: &appctest.RouteCollector{},
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(t.Logf, &appctest.RouteCollector{}, nil, nil)
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: &appctest.RouteCollector{}})
}
sys.Set(pm.Store())
sys.Set(eng)
@@ -332,9 +337,14 @@ func TestPeerAPIReplyToDNSQueriesAreObserved(t *testing.T) {
eng, _ := wgengine.NewFakeUserspaceEngine(logger.Discard, 0, ht, reg, sys.Bus.Get(), sys.Set)
var a *appc.AppConnector
if shouldStore {
a = appc.NewAppConnector(t.Logf, rc, &appc.RouteInfo{}, fakeStoreRoutes)
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(t.Logf, rc, nil, nil)
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
}
sys.Set(pm.Store())
sys.Set(eng)
@@ -399,9 +409,14 @@ func TestPeerAPIReplyToDNSQueriesAreObservedWithCNAMEFlattening(t *testing.T) {
pm := must.Get(newProfileManager(new(mem.Store), t.Logf, ht))
var a *appc.AppConnector
if shouldStore {
a = appc.NewAppConnector(t.Logf, rc, &appc.RouteInfo{}, fakeStoreRoutes)
a = appc.NewAppConnector(appc.Config{
Logf: t.Logf,
RouteAdvertiser: rc,
RouteInfo: &appc.RouteInfo{},
StoreRoutesFunc: fakeStoreRoutes,
})
} else {
a = appc.NewAppConnector(t.Logf, rc, nil, nil)
a = appc.NewAppConnector(appc.Config{Logf: t.Logf, RouteAdvertiser: rc})
}
sys.Set(pm.Store())
sys.Set(eng)