Skip to content

Commit 75b7922

Browse files
authored
Merge pull request #1730 from vrischmann/chore/ignore-link-local-addresses
clickhouse-http-client: ignore link local addresses in getLocalhost
2 parents 7a4140e + 27443b8 commit 75b7922

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ClickHouseHttpClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ private static HostNameAndAddress getLocalHost() {
4848
try {
4949
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
5050

51+
outer:
5152
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
5253
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
5354
for (InetAddress ia : Collections.list(inetAddresses)) {
5455
// We just use the first non-loopback address
55-
if (!ia.isLoopbackAddress()) {
56+
if (!ia.isLoopbackAddress() && !ia.isLinkLocalAddress()) {
5657
hostNameAndAddress.address = ia.getHostAddress();
5758
hostNameAndAddress.hostName = ia.getCanonicalHostName();
58-
break;
59+
break outer;
5960
}
6061
}
6162
}

0 commit comments

Comments
 (0)