You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/tailcfg/tailcfg_clone.go

62 lines
1.5 KiB
Go

// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// AUTO-GENERATED by tailscale.com/cmd/cloner -type User,Node,NetInfo
package tailcfg
import (
"github.com/tailscale/wireguard-go/wgcfg"
"time"
)
// Clone makes a deep copy of User.
// The result aliases no memory with the original.
func (src *User) Clone() *User {
if src == nil {
return nil
}
dst := new(User)
*dst = *src
dst.Logins = append([]LoginID(nil), src.Logins...)
dst.Roles = append([]RoleID(nil), src.Roles...)
return dst
}
// Clone makes a deep copy of Node.
// The result aliases no memory with the original.
func (src *Node) Clone() *Node {
if src == nil {
return nil
}
dst := new(Node)
*dst = *src
dst.Addresses = append([]wgcfg.CIDR(nil), src.Addresses...)
dst.AllowedIPs = append([]wgcfg.CIDR(nil), src.AllowedIPs...)
dst.Endpoints = append([]string(nil), src.Endpoints...)
dst.Hostinfo = *src.Hostinfo.Clone()
if dst.LastSeen != nil {
dst.LastSeen = new(time.Time)
*dst.LastSeen = *src.LastSeen
}
return dst
}
// Clone makes a deep copy of NetInfo.
// The result aliases no memory with the original.
func (src *NetInfo) Clone() *NetInfo {
if src == nil {
return nil
}
dst := new(NetInfo)
*dst = *src
if dst.DERPLatency != nil {
dst.DERPLatency = map[string]float64{}
for k, v := range src.DERPLatency {
dst.DERPLatency[k] = v
}
}
return dst
}