From d252e4cce0653bfd0930e710544ff164e8e3f0d3 Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Wed, 23 Oct 2024 11:24:16 -0700 Subject: [PATCH] Is able to handle IPv4 and IPv6 IpNetworks --- integration-tests/pkg/mock_sensor/server.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/integration-tests/pkg/mock_sensor/server.go b/integration-tests/pkg/mock_sensor/server.go index ecdaccbb21..0011d0f3ff 100644 --- a/integration-tests/pkg/mock_sensor/server.go +++ b/integration-tests/pkg/mock_sensor/server.go @@ -496,17 +496,18 @@ func (m *MockSensor) translateAddress(addr *sensorAPI.NetworkAddress) string { return peerId.String() } - // If there is no address data, IpNetwork should be set and represent - // a CIDR block or external IP address. + // If there is no address data, this is either the source address or + // IpNetwork should be set and represent a CIDR block or external IP address. ipNetworkData := addr.GetIpNetwork() if len(ipNetworkData) == 0 { return peerId.String() } - // If the prefix length is 32 this is a regular IP address - // and not a CIDR block + // If this is IPv4 and the prefix length is 32 or this is IPv6 and the prefix length + // is 128 this is a regular IP address and not a CIDR block ipNetwork := utils.IPNetworkFromCIDRBytes(ipNetworkData) - if ipNetwork.PrefixLen() == byte(32) { + if (len(ipNetworkData) == 5 && ipNetwork.PrefixLen() == byte(32)) || + (len(ipNetworkData) == 17 && ipNetwork.PrefixLen() == byte(128)) { peerId.Address = ipNetwork.IP() } else { peerId.IPNetwork = ipNetwork