2023-12-09 12:09:24 -05:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"tailscale.com/types/key"
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
|
|
|
|
var Comparers []cmp.Option = []cmp.Option{
|
2024-02-09 01:26:41 -05:00
|
|
|
IPComparer, PrefixComparer, AddrPortComparer, MkeyComparer, NkeyComparer, DkeyComparer,
|
2023-12-09 12:09:24 -05:00
|
|
|
}
|