2022-05-01 23:15:20 +00:00
|
|
|
// Copyright (c) 2022 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.
|
|
|
|
|
|
|
|
// Package tests serves a list of tests for tailscale.com/cmd/viewer.
|
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
all: convert more code to use net/netip directly
perl -i -npe 's,netaddr.IPPrefixFrom,netip.PrefixFrom,' $(git grep -l -F netaddr.)
perl -i -npe 's,netaddr.IPPortFrom,netip.AddrPortFrom,' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPrefix,netip.Prefix,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPort,netip.AddrPort,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IP\b,netip.Addr,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPv6Raw\b,netip.AddrFrom16,g' $(git grep -l -F netaddr. )
goimports -w .
Then delete some stuff from the net/netaddr shim package which is no
longer neeed.
Updates #5162
Change-Id: Ia7a86893fe21c7e3ee1ec823e8aba288d4566cd8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-26 04:14:09 +00:00
|
|
|
"net/netip"
|
2022-05-01 23:15:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:generate go run tailscale.com/cmd/viewer --type=StructWithPtrs,StructWithoutPtrs,Map,StructWithSlices
|
|
|
|
|
|
|
|
type StructWithoutPtrs struct {
|
|
|
|
Int int
|
all: convert more code to use net/netip directly
perl -i -npe 's,netaddr.IPPrefixFrom,netip.PrefixFrom,' $(git grep -l -F netaddr.)
perl -i -npe 's,netaddr.IPPortFrom,netip.AddrPortFrom,' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPrefix,netip.Prefix,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPort,netip.AddrPort,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IP\b,netip.Addr,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPv6Raw\b,netip.AddrFrom16,g' $(git grep -l -F netaddr. )
goimports -w .
Then delete some stuff from the net/netaddr shim package which is no
longer neeed.
Updates #5162
Change-Id: Ia7a86893fe21c7e3ee1ec823e8aba288d4566cd8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-26 04:14:09 +00:00
|
|
|
Pfx netip.Prefix
|
2022-05-01 23:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Map struct {
|
2022-05-09 16:30:39 +00:00
|
|
|
Int map[string]int
|
|
|
|
SliceInt map[string][]int
|
|
|
|
StructWithPtr map[string]*StructWithPtrs
|
|
|
|
StructWithoutPtr map[string]*StructWithoutPtrs
|
|
|
|
SlicesWithPtrs map[string][]*StructWithPtrs
|
|
|
|
SlicesWithoutPtrs map[string][]*StructWithoutPtrs
|
|
|
|
StructWithoutPtrKey map[StructWithoutPtrs]int `json:"-"`
|
|
|
|
|
|
|
|
// Unsupported.
|
|
|
|
SliceIntPtr map[string][]*int
|
|
|
|
PointerKey map[*string]int `json:"-"`
|
|
|
|
StructWithPtrKey map[StructWithPtrs]int `json:"-"`
|
2022-05-01 23:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type StructWithPtrs struct {
|
|
|
|
Value *StructWithoutPtrs
|
|
|
|
Int *int
|
|
|
|
|
|
|
|
NoCloneValue *StructWithoutPtrs `codegen:"noclone"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *StructWithPtrs) String() string { return fmt.Sprintf("%v", v.Int) }
|
|
|
|
|
|
|
|
func (v *StructWithPtrs) Equal(v2 *StructWithPtrs) bool {
|
|
|
|
return v.Value == v2.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
type StructWithSlices struct {
|
|
|
|
Values []StructWithoutPtrs
|
|
|
|
ValuePointers []*StructWithoutPtrs
|
|
|
|
StructPointers []*StructWithPtrs
|
|
|
|
Structs []StructWithPtrs
|
|
|
|
Ints []*int
|
|
|
|
|
|
|
|
Slice []string
|
all: convert more code to use net/netip directly
perl -i -npe 's,netaddr.IPPrefixFrom,netip.PrefixFrom,' $(git grep -l -F netaddr.)
perl -i -npe 's,netaddr.IPPortFrom,netip.AddrPortFrom,' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPrefix,netip.Prefix,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPort,netip.AddrPort,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IP\b,netip.Addr,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPv6Raw\b,netip.AddrFrom16,g' $(git grep -l -F netaddr. )
goimports -w .
Then delete some stuff from the net/netaddr shim package which is no
longer neeed.
Updates #5162
Change-Id: Ia7a86893fe21c7e3ee1ec823e8aba288d4566cd8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-26 04:14:09 +00:00
|
|
|
Prefixes []netip.Prefix
|
2022-05-01 23:15:20 +00:00
|
|
|
Data []byte
|
|
|
|
}
|