p2p/netutil: fix bug in RandomAddr

This commit is contained in:
Felix Lange 2024-05-30 16:17:43 +02:00
parent df945f7c45
commit 36e5fe2b19

View file

@ -356,7 +356,7 @@ func IPToAddr(ip net.IP) netip.Addr {
// RandomAddr creates a random IP address. // RandomAddr creates a random IP address.
func RandomAddr(rng *rand.Rand) netip.Addr { func RandomAddr(rng *rand.Rand) netip.Addr {
var bytes []byte var bytes []byte
if rng.Intn(1) == 0 { if rng.Intn(2) == 0 {
bytes = make([]byte, 4) bytes = make([]byte, 4)
} else { } else {
bytes = make([]byte, 16) bytes = make([]byte, 16)