mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-21 09:11:18 -08:00
ipn/ipnlocal: drop the appc import from ts_omit_appconnectors builds
LocalBackend named appc.AppConnector in its appConnector field, in the field's constructor call, and in the AppConnector accessor, so even builds with ts_omit_appconnectors linked the appc package and its dependencies. The buildfeatures.HasAppConnectors checks let the linker drop the code but could not remove the import. Add a build-tag-gated type for the field: appcAppConnector is an alias for appc.AppConnector by default, and in ts_omit_appconnectors builds it is an empty struct with no-op versions of the methods local.go calls, so the shared code still type checks. The constructor call moves behind a newAppConnector helper in the same gated file, and the AppConnector accessor keeps its *appc.AppConnector signature there, with a nil- returning version in the omitted build. This takes tailscale.com/appc out of depaware-min.txt and depaware-minbox.txt. Add a DepChecker test to keep it out; it also sets ts_omit_conn25, since conn25 uses appc as well. Updates #12614 Signed-off-by: Brad Fitzpatrick <[email protected]> Change-Id: Ia7e2d9c4f1b8e6a3d5c0f2b7e9a1c4d6f8b0e2a5
This commit is contained in:
1 parent
2d34ce3bbf
commit
2a61a720e5
6 files changed
+107
-38
No files matched your search
@@ -39,7 +39,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
💣 go4.org/mem from tailscale.com/control/controlbase+
|
||||
go4.org/netipx from tailscale.com/ipn/ipnlocal+
|
||||
tailscale.com from tailscale.com/version
|
||||
tailscale.com/appc from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/atomicfile from tailscale.com/ipn+
|
||||
tailscale.com/client/tailscale/apitype from tailscale.com/ipn/ipnauth+
|
||||
tailscale.com/cmd/tailscaled/childproc from tailscale.com/cmd/tailscaled
|
||||
@@ -142,7 +141,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/types/ipproto from tailscale.com/ipn+
|
||||
tailscale.com/types/key from tailscale.com/control/controlbase+
|
||||
tailscale.com/types/lazy from tailscale.com/hostinfo+
|
||||
tailscale.com/types/logger from tailscale.com/appc+
|
||||
tailscale.com/types/logger from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/types/logid from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/types/mapx from tailscale.com/ipn/ipnext+
|
||||
tailscale.com/types/netlogfunc from tailscale.com/net/tstun+
|
||||
@@ -154,19 +153,19 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/types/result from tailscale.com/util/lineiter
|
||||
tailscale.com/types/structs from tailscale.com/control/controlclient+
|
||||
tailscale.com/types/tkatype from tailscale.com/control/controlclient+
|
||||
tailscale.com/types/views from tailscale.com/appc+
|
||||
tailscale.com/types/views from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/backoff from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/bufiox from tailscale.com/types/key
|
||||
tailscale.com/util/checkchange from tailscale.com/ipn/ipnlocal+
|
||||
tailscale.com/util/cibuild from tailscale.com/health+
|
||||
tailscale.com/util/clientmetric from tailscale.com/appc+
|
||||
tailscale.com/util/clientmetric from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/cloudenv from tailscale.com/hostinfo+
|
||||
tailscale.com/util/cloudinfo from tailscale.com/wgengine/magicsock
|
||||
tailscale.com/util/ctxkey from tailscale.com/client/tailscale/apitype+
|
||||
tailscale.com/util/def from tailscale.com/ipn/localapi
|
||||
tailscale.com/util/dnsname from tailscale.com/appc+
|
||||
tailscale.com/util/dnsname from tailscale.com/hostinfo+
|
||||
tailscale.com/util/eventbus from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/execqueue from tailscale.com/appc+
|
||||
tailscale.com/util/execqueue from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/goroutines from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/groupmember from tailscale.com/ipn/ipnauth
|
||||
tailscale.com/util/httpbody from tailscale.com/control/controlclient+
|
||||
@@ -184,7 +183,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/util/ringlog from tailscale.com/wgengine/magicsock
|
||||
tailscale.com/util/set from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/singleflight from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/slicesx from tailscale.com/appc+
|
||||
tailscale.com/util/slicesx from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/syspolicy/pkey from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/util/syspolicy/policyclient from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/util/syspolicy/ptype from tailscale.com/ipn/ipnlocal+
|
||||
|
||||
@@ -44,7 +44,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
💣 go4.org/mem from tailscale.com/control/controlbase+
|
||||
go4.org/netipx from tailscale.com/ipn/ipnlocal+
|
||||
tailscale.com from tailscale.com/version
|
||||
tailscale.com/appc from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/atomicfile from tailscale.com/ipn+
|
||||
tailscale.com/client/local from tailscale.com/client/tailscale+
|
||||
tailscale.com/client/tailscale from tailscale.com/internal/client/tailscale
|
||||
@@ -161,7 +160,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/types/ipproto from tailscale.com/ipn+
|
||||
tailscale.com/types/key from tailscale.com/client/local+
|
||||
tailscale.com/types/lazy from tailscale.com/hostinfo+
|
||||
tailscale.com/types/logger from tailscale.com/appc+
|
||||
tailscale.com/types/logger from tailscale.com/cmd/tailscale/cli+
|
||||
tailscale.com/types/logid from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/types/mapx from tailscale.com/ipn/ipnext+
|
||||
tailscale.com/types/netlogfunc from tailscale.com/net/tstun+
|
||||
@@ -173,19 +172,19 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/types/result from tailscale.com/util/lineiter
|
||||
tailscale.com/types/structs from tailscale.com/control/controlclient+
|
||||
tailscale.com/types/tkatype from tailscale.com/control/controlclient+
|
||||
tailscale.com/types/views from tailscale.com/appc+
|
||||
tailscale.com/types/views from tailscale.com/cmd/tailscale/cli+
|
||||
tailscale.com/util/backoff from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/bufiox from tailscale.com/types/key
|
||||
tailscale.com/util/checkchange from tailscale.com/ipn/ipnlocal+
|
||||
tailscale.com/util/cibuild from tailscale.com/health+
|
||||
tailscale.com/util/clientmetric from tailscale.com/appc+
|
||||
tailscale.com/util/clientmetric from tailscale.com/client/local+
|
||||
tailscale.com/util/cloudenv from tailscale.com/hostinfo+
|
||||
tailscale.com/util/cloudinfo from tailscale.com/wgengine/magicsock
|
||||
tailscale.com/util/ctxkey from tailscale.com/client/tailscale/apitype+
|
||||
tailscale.com/util/def from tailscale.com/ipn/localapi
|
||||
tailscale.com/util/dnsname from tailscale.com/appc+
|
||||
tailscale.com/util/dnsname from tailscale.com/cmd/tailscale/cli+
|
||||
tailscale.com/util/eventbus from tailscale.com/client/local+
|
||||
tailscale.com/util/execqueue from tailscale.com/appc+
|
||||
tailscale.com/util/execqueue from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/goroutines from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/groupmember from tailscale.com/ipn/ipnauth
|
||||
tailscale.com/util/httpbody from tailscale.com/control/controlclient+
|
||||
@@ -205,7 +204,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/util/ringlog from tailscale.com/wgengine/magicsock
|
||||
tailscale.com/util/set from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/singleflight from tailscale.com/control/controlclient+
|
||||
tailscale.com/util/slicesx from tailscale.com/appc+
|
||||
tailscale.com/util/slicesx from tailscale.com/cmd/tailscale/cli+
|
||||
tailscale.com/util/syspolicy/pkey from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/util/syspolicy/policyclient from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/util/syspolicy/ptype from tailscale.com/ipn/ipnlocal+
|
||||
|
||||
@@ -81,6 +81,21 @@ func TestOmitDNSResolveCache(t *testing.T) {
|
||||
}.Check(t)
|
||||
}
|
||||
|
||||
func TestOmitAppConnectors(t *testing.T) {
|
||||
const msg = "unexpected app connector usage with ts_omit_appconnectors"
|
||||
deptest.DepChecker{
|
||||
GOOS: "linux",
|
||||
GOARCH: "amd64",
|
||||
// conn25 also uses appc, so omit it too to check that nothing
|
||||
// else pulls appc in.
|
||||
Tags: "ts_omit_appconnectors,ts_omit_conn25,ts_include_cli",
|
||||
BadDeps: map[string]string{
|
||||
"tailscale.com/appc": msg,
|
||||
"tailscale.com/feature/appconnectors": msg,
|
||||
},
|
||||
}.Check(t)
|
||||
}
|
||||
|
||||
func TestOmitSyspolicy(t *testing.T) {
|
||||
const msg = "unexpected syspolicy usage with ts_omit_syspolicy"
|
||||
deptest.DepChecker{
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_appconnectors
|
||||
|
||||
package ipnlocal
|
||||
|
||||
import (
|
||||
"tailscale.com/appc"
|
||||
"tailscale.com/types/appctype"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/util/eventbus"
|
||||
)
|
||||
|
||||
// appcAppConnector is [appc.AppConnector] in builds that include app
|
||||
// connectors. Builds with ts_omit_appconnectors substitute a stub type
|
||||
// (see appconnector_omit.go) so that this package does not import appc
|
||||
// at all, which keeps appc and its dependencies out of those binaries.
|
||||
type appcAppConnector = appc.AppConnector
|
||||
|
||||
// newAppConnector returns a new [appc.AppConnector] publishing to bus,
|
||||
// seeded with the previously stored routes in ri (which may be nil).
|
||||
func newAppConnector(logf logger.Logf, bus *eventbus.Bus, ri *appctype.RouteInfo, storeRoutes bool) *appcAppConnector {
|
||||
return appc.NewAppConnector(appc.Config{
|
||||
Logf: logf,
|
||||
EventBus: bus,
|
||||
RouteInfo: ri,
|
||||
HasStoredRoutes: storeRoutes,
|
||||
})
|
||||
}
|
||||
|
||||
// AppConnector returns the current AppConnector, or nil if not configured.
|
||||
//
|
||||
// TODO(nickkhyl): move app connectors to [nodeBackend], or perhaps a feature package?
|
||||
func (b *LocalBackend) AppConnector() *appc.AppConnector {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
return b.appConnector
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build ts_omit_appconnectors
|
||||
|
||||
package ipnlocal
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
"tailscale.com/types/appctype"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/util/eventbus"
|
||||
)
|
||||
|
||||
// appcAppConnector stands in for [tailscale.com/appc.AppConnector] in
|
||||
// builds without app connectors, so that this package does not import
|
||||
// appc. Its methods exist only so that the shared code in local.go type
|
||||
// checks; they are never reached, because every caller first checks
|
||||
// [buildfeatures.HasAppConnectors] and b.appConnector is always nil.
|
||||
type appcAppConnector struct{}
|
||||
|
||||
func newAppConnector(logf logger.Logf, bus *eventbus.Bus, ri *appctype.RouteInfo, storeRoutes bool) *appcAppConnector {
|
||||
panic("unreachable with ts_omit_appconnectors")
|
||||
}
|
||||
|
||||
func (*appcAppConnector) Close() {}
|
||||
func (*appcAppConnector) ShouldStoreRoutes() bool { return false }
|
||||
func (*appcAppConnector) UpdateDomainsAndRoutes(domains []string, routes []netip.Prefix) {}
|
||||
func (*appcAppConnector) DomainRoutes() map[string][]netip.Addr { return nil }
|
||||
func (*appcAppConnector) ObserveDNSResponse(res []byte) error { return nil }
|
||||
func (*appcAppConnector) ClearRoutes() error { return nil }
|
||||
|
||||
// AppConnector returns nil; app connectors are omitted from this build.
|
||||
func (b *LocalBackend) AppConnector() *appcAppConnector { return nil }
|
||||
+6
-24
@@ -35,7 +35,6 @@ import (
|
||||
"go4.org/mem"
|
||||
"go4.org/netipx"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"tailscale.com/appc"
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/control/controlknobs"
|
||||
@@ -325,10 +324,10 @@ type LocalBackend struct {
|
||||
conf *conffile.Config // latest parsed config, or nil if not in declarative mode
|
||||
pm *profileManager // mu guards access
|
||||
lastFilterInputs *filterInputs
|
||||
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
||||
ccGen clientGen // function for producing controlclient; lazily populated
|
||||
sshServer SSHServer // or nil, initialized lazily.
|
||||
appConnector *appc.AppConnector // or nil, initialized when configured.
|
||||
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
||||
ccGen clientGen // function for producing controlclient; lazily populated
|
||||
sshServer SSHServer // or nil, initialized lazily.
|
||||
appConnector *appcAppConnector // or nil, initialized when configured.
|
||||
// notifyCancel cancels notifications to the current SetNotifyCallback.
|
||||
notifyCancel context.CancelFunc
|
||||
cc controlclient.Client // TODO(nickkhyl): move to nodeBackend
|
||||
@@ -6012,12 +6011,7 @@ func (b *LocalBackend) reconfigAppConnectorLocked(selfNode tailcfg.NodeView, pre
|
||||
b.logf("Unsuccessful Read RouteInfo: %v", err)
|
||||
}
|
||||
b.appConnector.Close() // clean up a previous connector (safe on nil)
|
||||
b.appConnector = appc.NewAppConnector(appc.Config{
|
||||
Logf: b.logf,
|
||||
EventBus: b.sys.Bus.Get(),
|
||||
RouteInfo: ri,
|
||||
HasStoredRoutes: shouldStoreRoutes,
|
||||
})
|
||||
b.appConnector = newAppConnector(b.logf, b.sys.Bus.Get(), ri, shouldStoreRoutes)
|
||||
}
|
||||
if !selfNode.Valid() {
|
||||
return
|
||||
@@ -7910,18 +7904,6 @@ func (b *LocalBackend) OfferingAppConnector() bool {
|
||||
return b.appConnector != nil
|
||||
}
|
||||
|
||||
// AppConnector returns the current AppConnector, or nil if not configured.
|
||||
//
|
||||
// TODO(nickkhyl): move app connectors to [nodeBackend], or perhaps a feature package?
|
||||
func (b *LocalBackend) AppConnector() *appc.AppConnector {
|
||||
if !buildfeatures.HasAppConnectors {
|
||||
return nil
|
||||
}
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
return b.appConnector
|
||||
}
|
||||
|
||||
// allowExitNodeDNSProxyToServeName reports whether the Exit Node DNS
|
||||
// proxy is allowed to serve responses for the provided DNS name.
|
||||
func (b *LocalBackend) allowExitNodeDNSProxyToServeName(name string) bool {
|
||||
@@ -8604,7 +8586,7 @@ func (b *LocalBackend) ObserveDNSResponse(res []byte) error {
|
||||
if !buildfeatures.HasAppConnectors {
|
||||
return nil
|
||||
}
|
||||
var appConnector *appc.AppConnector
|
||||
var appConnector *appcAppConnector
|
||||
b.mu.Lock()
|
||||
if b.appConnector == nil {
|
||||
b.mu.Unlock()
|
||||
|
||||
Reference in new issue
Block a user