wgengine/filter: add a Clone method.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson 2021-01-22 14:26:39 -08:00
parent 9ce92aad3e
commit 9f7cbf6cf1
2 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,8 @@ import (
"tailscale.com/net/packet" "tailscale.com/net/packet"
) )
//go:generate go run tailscale.com/cmd/cloner --type=Match --output=match_clone.go
// PortRange is a range of TCP and UDP ports. // PortRange is a range of TCP and UDP ports.
type PortRange struct { type PortRange struct {
First, Last uint16 // inclusive First, Last uint16 // inclusive

View File

@ -0,0 +1,31 @@
// 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.
// Code generated by tailscale.com/cmd/cloner -type Match; DO NOT EDIT.
package filter
import (
"inet.af/netaddr"
)
// Clone makes a deep copy of Match.
// The result aliases no memory with the original.
func (src *Match) Clone() *Match {
if src == nil {
return nil
}
dst := new(Match)
*dst = *src
dst.Dsts = append(src.Dsts[:0:0], src.Dsts...)
dst.Srcs = append(src.Srcs[:0:0], src.Srcs...)
return dst
}
// A compilation failure here means this code must be regenerated, with command:
// tailscale.com/cmd/cloner -type Match
var _MatchNeedsRegeneration = Match(struct {
Dsts []NetPortRange
Srcs []netaddr.IPPrefix
}{})