From b76ca4110998a180ce7076f74f7f677a3fd068bc Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Thu, 13 May 2021 17:42:59 +0300 Subject: [PATCH] serializeAddress should always serialize as IPv6, since it assumes the IP size is 16 bytes (#1720) --- infrastructure/network/addressmanager/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/network/addressmanager/store.go b/infrastructure/network/addressmanager/store.go index efe0b1993..32fc216fb 100644 --- a/infrastructure/network/addressmanager/store.go +++ b/infrastructure/network/addressmanager/store.go @@ -243,7 +243,7 @@ func (as *addressStore) serializeAddress(address *address) []byte { serializedSize := 16 + 2 + 8 + 8 // ipv6 + port + timestamp + connectionFailedCount serializedNetAddress := make([]byte, serializedSize) - copy(serializedNetAddress[:], address.netAddress.IP[:]) + copy(serializedNetAddress[:], address.netAddress.IP.To16()[:]) binary.LittleEndian.PutUint16(serializedNetAddress[16:], address.netAddress.Port) binary.LittleEndian.PutUint64(serializedNetAddress[18:], uint64(address.netAddress.Timestamp.UnixMilliseconds())) binary.LittleEndian.PutUint64(serializedNetAddress[26:], uint64(address.connectionFailedCount))