diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2020-07-27 10:40:34 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2020-07-27 10:41:06 -0700 |
| commit | e6dbb4425ce4f0a6560b39143645dd1fbe66085b (patch) | |
| tree | ba026418dc6891b13306cacc86b84426b5aeb589 /tailcfg/tailcfg.go | |
| parent | 38b0c3eea27564af92416fa2cda9ae52f9aae08a (diff) | |
| download | tailscale-clone.tar.xz tailscale-clone.zip | |
cmd/cloner, tailcfg: fix nil vs len 0 issues, add tests, use for Hostinfoclone
Also use go:generate and https://golang.org/s/generatedcode header style.
Diffstat (limited to 'tailcfg/tailcfg.go')
| -rw-r--r-- | tailcfg/tailcfg.go | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 0e98f2a72..912005a6c 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -4,6 +4,8 @@ package tailcfg +//go:generate go run tailscale.com/cmd/cloner -type=User,Node,Hostinfo,NetInfo -output=tailcfg_clone.go + import ( "bytes" "errors" @@ -371,20 +373,6 @@ func (ni *NetInfo) BasicallyEqual(ni2 *NetInfo) bool { ni.LinkType == ni2.LinkType } -// Clone makes a deep copy of Hostinfo. -// The result aliases no memory with the original. -// -// TODO: use cmd/cloner, reconcile len(0) vs. nil. -func (h *Hostinfo) Clone() (res *Hostinfo) { - res = new(Hostinfo) - *res = *h - - res.RoutableIPs = append([]wgcfg.CIDR{}, h.RoutableIPs...) - res.Services = append([]Service{}, h.Services...) - res.NetInfo = h.NetInfo.Clone() - return res -} - // Equal reports whether h and h2 are equal. func (h *Hostinfo) Equal(h2 *Hostinfo) bool { if h == nil && h2 == nil { |
