2023-12-10 01:09:24 +08: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 14:26:41 +08:00
|
|
|
var AddrPortComparer = cmp.Comparer(func(x, y netip.AddrPort) bool {
|
|
|
|
return x == y
|
|
|
|
})
|
|
|
|
|
2023-12-10 01:09:24 +08: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 14:26:41 +08:00
|
|
|
IPComparer, PrefixComparer, AddrPortComparer, MkeyComparer, NkeyComparer, DkeyComparer,
|
2023-12-10 01:09:24 +08:00
|
|
|
}
|