From 611e0a5bcc42552849d02a9d78ed3a48c995c0a6 Mon Sep 17 00:00:00 2001 From: Tom DNetto Date: Wed, 22 Nov 2023 14:12:50 -0800 Subject: [PATCH] appc,ipn/local: support wildcard when matching app-connectors Updates: ENG-2453 Signed-off-by: Tom DNetto --- ipn/ipnlocal/local.go | 16 +++++++++------- types/appctype/appconnector.go | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index eca185038..cf1fd8990 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -3313,16 +3313,18 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i return } + // Geometric cost, assumes that the number of advertised tags is small + selfHasTag := func(attrTags []string) bool { + return nm.SelfNode.Tags().ContainsFunc(func(tag string) bool { + return slices.Contains(attrTags, tag) + }) + } + var domains []string for _, attr := range attrs { - // Geometric cost, assumes that the number of advertised tags is small - if !nm.SelfNode.Tags().ContainsFunc(func(tag string) bool { - return slices.Contains(attr.Connectors, tag) - }) { - continue + if slices.Contains(attr.Connectors, "*") || selfHasTag(attr.Connectors) { + domains = append(domains, attr.Domains...) } - - domains = append(domains, attr.Domains...) } slices.Sort(domains) slices.Compact(domains) diff --git a/types/appctype/appconnector.go b/types/appctype/appconnector.go index 5310d4de4..9602e7848 100644 --- a/types/appctype/appconnector.go +++ b/types/appctype/appconnector.go @@ -67,6 +67,7 @@ type AppConnectorAttr struct { // Domains can be of the form: example.com, or *.example.com. Domains []string `json:"domains,omitempty"` // Connectors enumerates the app connectors which service these domains. - // These can be any target type supported by Tailscale's ACL language. + // These can either be "*" to match any advertising connector, or a + // tag of the form tag:. Connectors []string `json:"connectors,omitempty"` }