mirror of https://github.com/tailscale/tailscale/
net/dns, ipn/ipnlocal: fix regressions from change moving away from deephash
I got sidetracked apparently and never finished writing this Clone
code in 316afe7d02 (#17448). (It really should use views instead.)
And then I missed one of the users of "routerChanged" that was broken up
into "routerChanged" vs "dnsChanged".
This broke integration tests elsewhere.
Fixes #17506
Change-Id: I533bf0fcf3da9ac6eb4a6cdef03b8df2c1fb4c8e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/17507/head
parent
7edb5b7d43
commit
f270c3158a
@ -0,0 +1,66 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"tailscale.com/types/dnstype"
|
||||
"tailscale.com/util/dnsname"
|
||||
)
|
||||
|
||||
func TestConfigClone(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
conf *Config
|
||||
}{
|
||||
{
|
||||
name: "nil",
|
||||
conf: nil,
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
conf: &Config{},
|
||||
},
|
||||
{
|
||||
name: "full",
|
||||
conf: &Config{
|
||||
DefaultResolvers: []*dnstype.Resolver{
|
||||
{
|
||||
Addr: "abc",
|
||||
BootstrapResolution: []netip.Addr{netip.MustParseAddr("1.2.3.4")},
|
||||
UseWithExitNode: true,
|
||||
},
|
||||
},
|
||||
Routes: map[dnsname.FQDN][]*dnstype.Resolver{
|
||||
"foo.bar.": {
|
||||
{
|
||||
Addr: "abc",
|
||||
BootstrapResolution: []netip.Addr{netip.MustParseAddr("1.2.3.4")},
|
||||
UseWithExitNode: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
SearchDomains: []dnsname.FQDN{"bar.baz."},
|
||||
Hosts: map[dnsname.FQDN][]netip.Addr{
|
||||
"host.bar.": {netip.MustParseAddr("5.6.7.8")},
|
||||
},
|
||||
OnlyIPv6: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := tt.conf.Clone()
|
||||
if !reflect.DeepEqual(got, tt.conf) {
|
||||
t.Error("Cloned result is not reflect.DeepEqual")
|
||||
}
|
||||
if !got.Equal(tt.conf) {
|
||||
t.Error("Cloned result is not Equal")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue