2023-12-09 12:09:24 -05:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
2024-08-27 12:54:28 -04:00
|
|
|
"tailscale.com/types/ipproto"
|
2023-12-09 12:09:24 -05:00
|
|
|
"tailscale.com/types/key"
|
2024-08-27 12:54:28 -04:00
|
|
|
"tailscale.com/types/views"
|
2023-12-09 12:09:24 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
var PrefixComparer = cmp.Comparer(func(x, y netip.Prefix) bool {
|
|
|
|
return x == y
|
|
|
|
})
|
|
|
|
|
|
|
|
var IPComparer = cmp.Comparer(func(x, y netip.Addr) bool {
|
|
|
|
return x.Compare(y) == 0
|
|
|
|
})
|
|
|
|
|
2024-02-09 01:26:41 -05:00
|
|
|
var AddrPortComparer = cmp.Comparer(func(x, y netip.AddrPort) bool {
|
|
|
|
return x == y
|
|
|
|
})
|
|
|
|
|
2023-12-09 12:09:24 -05:00
|
|
|
var MkeyComparer = cmp.Comparer(func(x, y key.MachinePublic) bool {
|
|
|
|
return x.String() == y.String()
|
|
|
|
})
|
|
|
|
|
|
|
|
var NkeyComparer = cmp.Comparer(func(x, y key.NodePublic) bool {
|
|
|
|
return x.String() == y.String()
|
|
|
|
})
|
|
|
|
|
|
|
|
var DkeyComparer = cmp.Comparer(func(x, y key.DiscoPublic) bool {
|
|
|
|
return x.String() == y.String()
|
|
|
|
})
|
|
|
|
|
2024-08-27 12:54:28 -04:00
|
|
|
var ViewSliceIPProtoComparer = cmp.Comparer(func(a, b views.Slice[ipproto.Proto]) bool { return views.SliceEqual(a, b) })
|
|
|
|
|
2023-12-09 12:09:24 -05:00
|
|
|
var Comparers []cmp.Option = []cmp.Option{
|
2024-08-27 12:54:28 -04:00
|
|
|
IPComparer, PrefixComparer, AddrPortComparer, MkeyComparer, NkeyComparer, DkeyComparer, ViewSliceIPProtoComparer,
|
2023-12-09 12:09:24 -05:00
|
|
|
}
|