net/dns, wgengine: use viewer/cloner for Config
Per earlier TODO. Updates #17506 Change-Id: I21fe851c4bcced98fcee844cb428ca9c2f6b0588 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
f270c3158a
commit
9123932710
+2
-20
@@ -1,13 +1,14 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:generate go run tailscale.com/cmd/viewer --type=Config --clonefunc
|
||||
|
||||
// Package dns contains code to configure and manage DNS settings.
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"slices"
|
||||
@@ -191,25 +192,6 @@ func sameResolverNames(a, b []*dnstype.Resolver) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Clone makes a shallow clone of c.
|
||||
//
|
||||
// The returned Config still references slices and maps from c.
|
||||
//
|
||||
// TODO(bradfitz): use cmd/{viewer,cloner} for these and make the
|
||||
// caller use views instead.
|
||||
func (c *Config) Clone() *Config {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return &Config{
|
||||
DefaultResolvers: slices.Clone(c.DefaultResolvers),
|
||||
Routes: maps.Clone(c.Routes),
|
||||
SearchDomains: slices.Clone(c.SearchDomains),
|
||||
Hosts: maps.Clone(c.Hosts),
|
||||
OnlyIPv6: c.OnlyIPv6,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) Equal(o *Config) bool {
|
||||
if c == nil || o == nil {
|
||||
return c == o
|
||||
|
||||
Reference in New Issue
Block a user