types/views: add generic Slice[T] and remove StringSlice

Also make IPPrefixSliceOf use Slice[netaddr.IPPrefix] as it also
provides additional functions besides the standard ones provided by
Slice[T].

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-03-16 21:45:19 -07:00
committed by Maisem Ali
parent d8953bf2ba
commit 6b9d938c1a
5 changed files with 48 additions and 52 deletions

View File

@@ -444,10 +444,10 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
exitNodeOption := tsaddr.PrefixesContainsFunc(p.AllowedIPs, func(r netaddr.IPPrefix) bool {
return r.Bits() == 0
})
var tags *views.StringSlice
var tags *views.Slice[string]
var primaryRoutes *views.IPPrefixSlice
if p.Tags != nil {
v := views.StringSliceOf(p.Tags)
v := views.SliceOf(p.Tags)
tags = &v
}
if p.PrimaryRoutes != nil {

View File

@@ -112,7 +112,7 @@ type PeerStatus struct {
// Tags are the list of ACL tags applied to this node.
// See tailscale.com/tailcfg#Node.Tags for more information.
Tags *views.StringSlice `json:",omitempty"`
Tags *views.Slice[string] `json:",omitempty"`
// PrimaryRoutes are the routes this node is currently the primary
// subnet router for, as determined by the control plane. It does