Skip to content

Commit

Permalink
Translate IPv4 to IPv6 to fix issue #1843
Browse files Browse the repository at this point in the history
Change-Id: I1e04122d9e0cd7cd5986e9b33b0fad74d22c1937
  • Loading branch information
javeme committed Apr 27, 2022
1 parent b87c9ce commit 6077187
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.IOException;
import java.lang.management.MemoryUsage;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -297,7 +299,15 @@ private Map<String, Object> executeAllHosts(Function<String, Object> func) {
Map<String, Object> hostsResults = InsertionOrderUtil.newMap();
for (Host host : hosts) {
InetAddress address = host.getAddress();
String hostAddress = address.getHostAddress();
String hostAddress;
if (address instanceof Inet4Address) {
hostAddress = host.getAddress().getHostAddress();
// Translate IPv4 to IPv6 to fix issue #1843
hostAddress = "::FFFF:" + hostAddress;
} else {
assert address instanceof Inet6Address;
hostAddress = host.getAddress().getHostAddress();
}
hostsResults.put(hostAddress, func.apply(hostAddress));
}
results.put(SERVERS, hostsResults);
Expand Down

0 comments on commit 6077187

Please sign in to comment.