mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 02:31:18 -08:00
appc,feature/conn25: build split DNS routes from the parsed config
On every self node change, conn25 parsed the app connector capability twice: once in configFromNodeView, and again in appc.AppDNSRoutes to build the split DNS routes. Build the routes from the config we already have instead, and move DNSAddrScheme into feature/conn25 along with it. With appc/conn25.go gone, conn25 no longer depends on appc, so TestOmitAppConnectors no longer needs to omit conn25 too. Fixes tailscale/corp#51400 Fixes tailscale/corp#51402 Signed-off-by: Michael Ben-Ami <[email protected]>
This commit is contained in:
1 parent
0afa9614d3
commit
7caf9edb40
6 files changed
+175
-270
No files matched your search
@@ -1,57 +0,0 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package appc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tailcfg/nodecap"
|
||||
"tailscale.com/types/appctype"
|
||||
"tailscale.com/types/dnstype"
|
||||
)
|
||||
|
||||
const AppConnectorAttrName = "tailscale.com/app-connectors"
|
||||
|
||||
// DNSAddrScheme is the custom URI scheme used for conn25-managed split DNS
|
||||
// entries to determine the destination at query time rather than configuration
|
||||
// time.
|
||||
const DNSAddrScheme = "tailscale-app"
|
||||
|
||||
// AppDNSRoutes returns split DNS routes, keyed by domain suffix, for the app
|
||||
// domains configured in self's capability map. Each route resolves via the
|
||||
// [DNSAddrScheme] scheme naming the app, so the connector that serves it is
|
||||
// chosen at query time. It returns nil if the node lacks Connectors 2025 apps.
|
||||
func AppDNSRoutes(hasCap func(c nodecap.Cap) bool, self tailcfg.NodeView) map[string][]*dnstype.Resolver {
|
||||
if !hasCap(AppConnectorAttrName) {
|
||||
return nil
|
||||
}
|
||||
|
||||
apps, err := tailcfg.UnmarshalNodeCapViewJSON[appctype.AppConnectorAttr](self.CapMap(), AppConnectorAttrName)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
appNamesByDomain := map[string]string{}
|
||||
for _, app := range apps {
|
||||
// conn25 apps are provided under [AppConnectorAttrName] with the Mode
|
||||
// field set to [appctype.AppConnectorModeMagicIP].
|
||||
if app.Mode != appctype.MagicIP {
|
||||
continue
|
||||
}
|
||||
for _, domain := range app.Domains {
|
||||
domain, _ = strings.CutPrefix(domain, "*.")
|
||||
domain = strings.ToLower(domain)
|
||||
// in the case of multiple apps specifying the same domain (which is misconfiguration
|
||||
// that should be validated at point of input) last write wins.
|
||||
appNamesByDomain[domain] = app.Name
|
||||
}
|
||||
}
|
||||
m := make(map[string][]*dnstype.Resolver, len(appNamesByDomain))
|
||||
for domain, appName := range appNamesByDomain {
|
||||
m[domain] = []*dnstype.Resolver{{Addr: fmt.Sprintf("%s:%s", DNSAddrScheme, appName), UseWithExitNode: true}}
|
||||
}
|
||||
return m
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package appc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tailcfg/nodecap"
|
||||
"tailscale.com/types/appctype"
|
||||
"tailscale.com/types/dnstype"
|
||||
)
|
||||
|
||||
func TestAppDNSRoutes(t *testing.T) {
|
||||
getBytesForAttr := func(name string, domains []string, tags []string, mode appctype.Mode) []byte {
|
||||
attr := appctype.AppConnectorAttr{
|
||||
Name: name,
|
||||
Domains: domains,
|
||||
Connectors: tags,
|
||||
Mode: mode,
|
||||
}
|
||||
bs, err := json.Marshal(attr)
|
||||
if err != nil {
|
||||
t.Fatalf("test setup: %v", err)
|
||||
}
|
||||
return bs
|
||||
}
|
||||
appOneBytes := getBytesForAttr(
|
||||
"app1",
|
||||
[]string{"example.com"},
|
||||
[]string{"tag:one"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
appTwoBytes := getBytesForAttr(
|
||||
"app2",
|
||||
[]string{"a.example.com"},
|
||||
[]string{"tag:two"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
appThreeBytes := getBytesForAttr(
|
||||
"app3",
|
||||
[]string{"woo.b.example.com", "hoo.b.example.com"},
|
||||
[]string{"tag:three1", "tag:three2"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
appFourBytes := getBytesForAttr(
|
||||
"app4",
|
||||
[]string{"woo.b.example.com", "c.example.com"},
|
||||
[]string{"tag:four1", "tag:four2"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
appFiveBytes := getBytesForAttr(
|
||||
"app5",
|
||||
[]string{"*.example.com", "example.com"},
|
||||
[]string{"tag:one"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
appSixBytes := getBytesForAttr(
|
||||
"app6",
|
||||
[]string{"*.Example.com", "EXAMPLE.com", "EXAMPLE.COM"},
|
||||
[]string{"tag:one"},
|
||||
appctype.MagicIP,
|
||||
)
|
||||
subnetAppBytes := getBytesForAttr(
|
||||
"subnet-app",
|
||||
[]string{"subnet.example.com"},
|
||||
[]string{"tag:one"},
|
||||
appctype.Subnet,
|
||||
)
|
||||
|
||||
resolver := func(appName string) []*dnstype.Resolver {
|
||||
return []*dnstype.Resolver{{Addr: fmt.Sprintf("%s:%s", DNSAddrScheme, appName), UseWithExitNode: true}}
|
||||
}
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
hasCap bool
|
||||
config []tailcfg.RawMessage
|
||||
want map[string][]*dnstype.Resolver
|
||||
}{
|
||||
{
|
||||
name: "no-capability", // hasCap false should return nil regardless of config.
|
||||
hasCap: false,
|
||||
},
|
||||
{
|
||||
name: "no-apps", // hasCap true but no configured apps returns an empty map.
|
||||
hasCap: true,
|
||||
want: map[string][]*dnstype.Resolver{},
|
||||
},
|
||||
{
|
||||
name: "bad-config", // bad config should return nil rather than error.
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{tailcfg.RawMessage(`hey`)},
|
||||
},
|
||||
{
|
||||
name: "single-app",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{tailcfg.RawMessage(appOneBytes)},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"example.com": resolver("app1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "single-app-multi-domain",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{tailcfg.RawMessage(appThreeBytes)},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"woo.b.example.com": resolver("app3"),
|
||||
"hoo.b.example.com": resolver("app3"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multi-app-no-overlap",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{
|
||||
tailcfg.RawMessage(appOneBytes),
|
||||
tailcfg.RawMessage(appTwoBytes),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"example.com": resolver("app1"),
|
||||
"a.example.com": resolver("app2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "domain-collision-last-write-wins",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{
|
||||
tailcfg.RawMessage(appThreeBytes), // app3: woo.b.example.com, hoo.b.example.com
|
||||
tailcfg.RawMessage(appFourBytes), // app4: woo.b.example.com, c.example.com
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// app4 overwrites app3 for the shared domain
|
||||
"woo.b.example.com": resolver("app4"),
|
||||
"hoo.b.example.com": resolver("app3"),
|
||||
"c.example.com": resolver("app4"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "wildcards-are-stripped-and-deduped",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{tailcfg.RawMessage(appFiveBytes)},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// *.example.com and example.com should both normalize to example.com.
|
||||
"example.com": resolver("app5"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "domains-are-normalized-and-deduped",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{tailcfg.RawMessage(appSixBytes)},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// *.Example.com, EXAMPLE.com, EXAMPLE.COM should all normalize to example.com.
|
||||
"example.com": resolver("app6"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sub-domains-and-top-domains-do-not-collide",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{
|
||||
tailcfg.RawMessage(appTwoBytes),
|
||||
tailcfg.RawMessage(appFiveBytes),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// *.example.com normalizes to example.com; a.example.com remains distinct.
|
||||
"a.example.com": resolver("app2"),
|
||||
"example.com": resolver("app5"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "only-conn25-processed",
|
||||
hasCap: true,
|
||||
config: []tailcfg.RawMessage{
|
||||
tailcfg.RawMessage(appOneBytes),
|
||||
tailcfg.RawMessage(subnetAppBytes),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// The app that's a subnet router should not show up here,
|
||||
// since we only deal with conn25 apps.
|
||||
"example.com": resolver("app1"),
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
selfNode := &tailcfg.Node{}
|
||||
if tt.config != nil {
|
||||
selfNode.CapMap = tailcfg.NodeCapMap{
|
||||
nodecap.Cap(AppConnectorAttrName): tt.config,
|
||||
}
|
||||
}
|
||||
selfView := selfNode.View()
|
||||
got := AppDNSRoutes(func(_ nodecap.Cap) bool {
|
||||
return tt.hasCap
|
||||
}, selfView)
|
||||
if diff := cmp.Diff(tt.want, got); diff != "" {
|
||||
t.Fatalf("AppDNSRoutes (-want, +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
gvisor.dev/gvisor/pkg/tcpip/transport/udp from gvisor.dev/gvisor/pkg/tcpip/adapters/gonet+
|
||||
gvisor.dev/gvisor/pkg/waiter from gvisor.dev/gvisor/pkg/context+
|
||||
tailscale.com from tailscale.com/version
|
||||
tailscale.com/appc from tailscale.com/ipn/ipnlocal+
|
||||
tailscale.com/appc from tailscale.com/ipn/ipnlocal
|
||||
💣 tailscale.com/atomicfile from tailscale.com/ipn+
|
||||
LD tailscale.com/chirp from tailscale.com/feature/bird
|
||||
tailscale.com/client/local from tailscale.com/client/web+
|
||||
|
||||
@@ -86,9 +86,7 @@ func TestOmitAppConnectors(t *testing.T) {
|
||||
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",
|
||||
Tags: "ts_omit_appconnectors,ts_include_cli",
|
||||
BadDeps: map[string]string{
|
||||
"tailscale.com/appc": msg,
|
||||
"tailscale.com/feature/appconnectors": msg,
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"go4.org/netipx"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"tailscale.com/appc"
|
||||
"tailscale.com/feature"
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/ipn/ipnext"
|
||||
@@ -169,9 +168,9 @@ func (e *extension) installHooks(dph *datapathHandler) error {
|
||||
return errors.New("dns manager resolver not ready")
|
||||
}
|
||||
|
||||
if err := r.RegisterCustomScheme(appc.DNSAddrScheme, func(addr string) (string, error) {
|
||||
if err := r.RegisterCustomScheme(DNSAddrScheme, func(addr string) (string, error) {
|
||||
scheme, appName, ok := strings.Cut(addr, ":")
|
||||
if !ok || scheme != appc.DNSAddrScheme {
|
||||
if !ok || scheme != DNSAddrScheme {
|
||||
return "", fmt.Errorf("unexpected conn25 scheme %q", scheme)
|
||||
}
|
||||
|
||||
@@ -266,7 +265,7 @@ func (e *extension) installHooks(dph *datapathHandler) error {
|
||||
})
|
||||
|
||||
// Route DNS queries for app domains to the connector that serves
|
||||
// them, chosen at query time via the [appc.DNSAddrScheme] scheme.
|
||||
// them, chosen at query time via the [DNSAddrScheme] scheme.
|
||||
e.host.Hooks().ExtraDNSRoutes.Set(func() map[string][]*dnstype.Resolver {
|
||||
if !e.conn25.isConfigured() {
|
||||
return nil
|
||||
@@ -468,7 +467,7 @@ func (e *extension) onSelfChange(selfNode tailcfg.NodeView) {
|
||||
}
|
||||
// Store the routes only once the config parsed, so a bad self node
|
||||
// leaves the previous routes and config in place together.
|
||||
e.conn25.appDNSRoutes.Store(appc.AppDNSRoutes(selfNode.HasCap, selfNode))
|
||||
e.conn25.appDNSRoutes.Store(cfg.appDNSRoutes())
|
||||
e.conn25.reconfig(cfg)
|
||||
}
|
||||
|
||||
@@ -508,7 +507,7 @@ type Conn25 struct {
|
||||
prefsAdvertiseConnector atomic.Bool
|
||||
|
||||
// appDNSRoutes holds the split DNS routes for the app domains in the
|
||||
// self node's capabilities, as returned by [appc.AppDNSRoutes]. It is
|
||||
// self node's capabilities, as returned by [config.appDNSRoutes]. It is
|
||||
// recomputed on each self node change and served to
|
||||
// [ipnext.Hooks.ExtraDNSRoutes]. The map must not be mutated once stored.
|
||||
appDNSRoutes syncs.AtomicValue[map[string][]*dnstype.Resolver]
|
||||
@@ -748,6 +747,11 @@ type ConnectorTransitIPResponse struct {
|
||||
const (
|
||||
AppConnectorAttrName = "tailscale.com/app-connectors"
|
||||
AppConnectorsExperimentalIPPoolsAttrName = "tailscale.com/app-connectors-experimental-ippools"
|
||||
|
||||
// DNSAddrScheme is the custom URI scheme used for conn25-managed split DNS
|
||||
// entries to determine the destination at query time rather than configuration
|
||||
// time.
|
||||
DNSAddrScheme = "tailscale-app"
|
||||
)
|
||||
|
||||
// ipSets wraps all the IPSets the config needs.
|
||||
@@ -893,6 +897,33 @@ func (cfg *config) getAppsForConnectorDomain(domain dnsname.FQDN, prefsAdvertise
|
||||
return appNames
|
||||
}
|
||||
|
||||
// appDNSRoutes returns split DNS routes, keyed by domain suffix, for the app
|
||||
// domains in cfg. Each route resolves via the [DNSAddrScheme] scheme naming
|
||||
// the app, so the connector that serves it is chosen at query time. It
|
||||
// returns nil if cfg is not configured.
|
||||
func (cfg *config) appDNSRoutes() map[string][]*dnstype.Resolver {
|
||||
if !cfg.isConfigured {
|
||||
return nil
|
||||
}
|
||||
m := make(map[string][]*dnstype.Resolver, len(cfg.appNamesByDomain)+len(cfg.appNamesByWCDomain))
|
||||
add := func(byDomain map[dnsname.FQDN][]string) {
|
||||
for domain, appNames := range byDomain {
|
||||
if len(appNames) == 0 {
|
||||
continue
|
||||
}
|
||||
// In the case of multiple apps specifying the same domain (which is misconfiguration
|
||||
// that should be validated at point of input), the last one in the config list wins.
|
||||
appName := appNames[len(appNames)-1]
|
||||
m[domain.WithoutTrailingDot()] = []*dnstype.Resolver{{Addr: fmt.Sprintf("%s:%s", DNSAddrScheme, appName), UseWithExitNode: true}}
|
||||
}
|
||||
}
|
||||
// If an exact and a wildcard domain coincide, the exact domain's app
|
||||
// takes the route, so add it last.
|
||||
add(cfg.appNamesByWCDomain)
|
||||
add(cfg.appNamesByDomain)
|
||||
return m
|
||||
}
|
||||
|
||||
func (e *extension) sendLoop(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
|
||||
@@ -4138,6 +4138,142 @@ func TestHandleHookReplyToDNSQueries(t *testing.T) {
|
||||
// for the app domains in the self node's capabilities, and supplies none
|
||||
// before the self node is known, when this node is itself a connector, or
|
||||
// after a switch to a different node.
|
||||
func TestAppDNSRoutes(t *testing.T) {
|
||||
app := func(name string, mode appctype.Mode, domains ...string) appctype.AppConnectorAttr {
|
||||
return appctype.AppConnectorAttr{
|
||||
Name: name,
|
||||
Domains: domains,
|
||||
Connectors: []string{"tag:" + name},
|
||||
Mode: mode,
|
||||
}
|
||||
}
|
||||
resolver := func(appName string) []*dnstype.Resolver {
|
||||
return []*dnstype.Resolver{{Addr: fmt.Sprintf("%s:%s", DNSAddrScheme, appName), UseWithExitNode: true}}
|
||||
}
|
||||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
apps []appctype.AppConnectorAttr
|
||||
want map[string][]*dnstype.Resolver
|
||||
}{
|
||||
{
|
||||
name: "no-apps", // an unconfigured config has no routes.
|
||||
},
|
||||
{
|
||||
name: "only-subnet-apps", // no conn25 apps means unconfigured.
|
||||
apps: []appctype.AppConnectorAttr{app("subnet-app", appctype.Subnet, "subnet.example.com")},
|
||||
},
|
||||
{
|
||||
name: "single-app",
|
||||
apps: []appctype.AppConnectorAttr{app("app1", appctype.MagicIP, "example.com")},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"example.com": resolver("app1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "single-app-multi-domain",
|
||||
apps: []appctype.AppConnectorAttr{app("app3", appctype.MagicIP, "woo.b.example.com", "hoo.b.example.com")},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"woo.b.example.com": resolver("app3"),
|
||||
"hoo.b.example.com": resolver("app3"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multi-app-no-overlap",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app1", appctype.MagicIP, "example.com"),
|
||||
app("app2", appctype.MagicIP, "a.example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"example.com": resolver("app1"),
|
||||
"a.example.com": resolver("app2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "domain-collision-last-wins",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app3", appctype.MagicIP, "woo.b.example.com", "hoo.b.example.com"),
|
||||
app("app4", appctype.MagicIP, "woo.b.example.com", "c.example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// app4 is listed last, so takes the shared domain.
|
||||
"woo.b.example.com": resolver("app4"),
|
||||
"hoo.b.example.com": resolver("app3"),
|
||||
"c.example.com": resolver("app4"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "wildcard-collision-last-wins",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app1", appctype.MagicIP, "*.example.com"),
|
||||
app("app2", appctype.MagicIP, "*.example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
"example.com": resolver("app2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "exact-beats-wildcard",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app1", appctype.MagicIP, "example.com"),
|
||||
app("app2", appctype.MagicIP, "*.example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// The exact app wins even though the wildcard app is listed last.
|
||||
"example.com": resolver("app1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "wildcards-are-stripped-and-deduped",
|
||||
apps: []appctype.AppConnectorAttr{app("app5", appctype.MagicIP, "*.example.com", "example.com")},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// *.example.com and example.com should both normalize to example.com.
|
||||
"example.com": resolver("app5"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "domains-are-normalized-and-deduped",
|
||||
apps: []appctype.AppConnectorAttr{app("app6", appctype.MagicIP, "*.Example.com", "EXAMPLE.com", "EXAMPLE.COM", "example.com.")},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// All variants should normalize to example.com.
|
||||
"example.com": resolver("app6"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sub-domains-and-top-domains-do-not-collide",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app2", appctype.MagicIP, "a.example.com"),
|
||||
app("app5", appctype.MagicIP, "*.example.com", "example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// *.example.com normalizes to example.com; a.example.com remains distinct.
|
||||
"a.example.com": resolver("app2"),
|
||||
"example.com": resolver("app5"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "only-conn25-processed",
|
||||
apps: []appctype.AppConnectorAttr{
|
||||
app("app1", appctype.MagicIP, "example.com"),
|
||||
app("subnet-app", appctype.Subnet, "subnet.example.com"),
|
||||
},
|
||||
want: map[string][]*dnstype.Resolver{
|
||||
// The app that's a subnet router should not show up here,
|
||||
// since we only deal with conn25 apps.
|
||||
"example.com": resolver("app1"),
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfg := mustConfig(t, makeSelfNode(t, tt.apps, appctype.Conn25PoolsAttr{}, nil))
|
||||
got := cfg.appDNSRoutes()
|
||||
if diff := cmp.Diff(tt.want, got); diff != "" {
|
||||
t.Fatalf("appDNSRoutes (-want, +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtraDNSRoutesHook(t *testing.T) {
|
||||
ext := &extension{
|
||||
conn25: newConn25(logger.Discard),
|
||||
|
||||
Reference in new issue
Block a user