tailscale/util
Joe Tsai d32700c7b2
util/deephash: specialize for netip.Addr and drop AppendTo support (#5402)
There are 5 types that we care about that implement AppendTo:

	key.DiscoPublic
	key.NodePublic
	netip.Prefix
	netipx.IPRange
	netip.Addr

The key types are thin wrappers around [32]byte and are memory hashable.
The netip.Prefix and netipx.IPRange types are thin wrappers over netip.Addr
and are hashable by default if netip.Addr is hashable.
The netip.Addr type is the only one with a complex structure where
the default behavior of deephash does not hash it correctly due to the presence
of the intern.Value type.

Drop support for AppendTo and instead add specialized hashing for netip.Addr
that would be semantically equivalent to == on the netip.Addr values.

The AppendTo support was already broken prior to this change.
It was fully removed (intentionally or not) in #4870.
It was partially restored in #4858 for the fast path,
but still broken in the slow path.
Just drop support for it altogether.

This does mean we lack any ability for types to self-hash themselves.
In the future we can add support for types that implement:

	interface { DeepHash() Sum }

Test and fuzz cases were added for the relevant types that
used to rely on the AppendTo method.
FuzzAddr has been executed on 1 billion samples without issues.

Signed-off-by: Joe Tsai joetsai@digital-static.net
2022-08-18 22:54:56 -07:00
..
cibuild all: use cibuild.On 2022-03-18 15:19:26 -07:00
clientmetric all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
cloudenv all: use syncs.AtomicValue 2022-08-04 11:52:16 -07:00
cmpver util/cmpver: move into OSS from corp repo. 2021-04-23 20:55:45 -07:00
codegen all: convert more code to use net/netip directly 2022-07-25 21:53:49 -07:00
deephash util/deephash: specialize for netip.Addr and drop AppendTo support (#5402) 2022-08-18 22:54:56 -07:00
dnsname all: use Go 1.18's strings.Cut 2022-03-16 14:53:59 -07:00
endian all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
groupmember util/groupmember: remove redundant code (#4298) 2022-03-26 21:45:06 -07:00
hashx util/hashx: move from sha256x (#5388) 2022-08-16 13:15:33 -07:00
jsonutil all: use any instead of interface{} 2022-03-17 11:35:09 -07:00
lineread util/lineread: add docs to Reader 2020-11-19 12:14:58 -08:00
mak util/mak: move tailssh's mapSet into a new package for reuse elsewhere 2022-04-21 21:20:10 -07:00
multierr all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
must util/must: rename Do->Get, add Do 2022-08-06 09:30:10 -07:00
osshare all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
pidowner all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
precompress cmd/tsconnect,util/precompress: move precompression to its own package 2022-08-03 17:44:57 -07:00
racebuild all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
singleflight all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
strs util/strs: add new package for string utility funcs 2022-08-05 15:06:08 -07:00
systemd all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
uniq all: use any instead of interface{} 2022-03-17 11:35:09 -07:00
winutil util/winutil: consolidate interface specific registry keys 2022-08-14 22:34:59 -07:00