Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoukoVirtanen committed Oct 23, 2024
1 parent d252e4c commit 7760477
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions integration-tests/pkg/mock_sensor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,12 @@ func (m *MockSensor) translateAddress(addr *sensorAPI.NetworkAddress) string {
return peerId.String()
}

ipNetwork := utils.IPNetworkFromCIDRBytes(ipNetworkData)
numBytes := len(ipNetworkData)
prefixLen := ipNetwork.PrefixLen()
// 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 (len(ipNetworkData) == 5 && ipNetwork.PrefixLen() == byte(32)) ||
(len(ipNetworkData) == 17 && ipNetwork.PrefixLen() == byte(128)) {
if (numBytes == 5 && prefixLen == byte(32)) || (numBytes == 17 && prefixLen == byte(128)) {
peerId.Address = ipNetwork.IP()
} else {
peerId.IPNetwork = ipNetwork
Expand Down

0 comments on commit 7760477

Please sign in to comment.