Skip to content

Commit

Permalink
skip IP address when hostname-for-clients has been provided
Browse files Browse the repository at this point in the history
for cases where client-bind-address is an internal IP address (behind a firewall)
or 0.0.0.0 etc, then adding the IP address to hostname-for-clients specified
value can result in incorrect client behaviour, so skip adding IP address
for such cases

updated FabricServerTest for the above change
  • Loading branch information
sumwale committed Jun 25, 2021
1 parent 185e02c commit 25ddfef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ public abstract class NetworkInterfaceImpl implements NetworkInterface,

protected InetAddress inetAddress;

protected volatile String hostNameForClients;

protected volatile String hostName;

protected int port;
Expand Down Expand Up @@ -1100,7 +1102,8 @@ public final String asString() {
public final String getHostName() {
final String hostName = getHostNameForClients();
if (hostName != null) {
return hostName;
return this.hostNameForClients != null ? this.hostNameForClients
: hostName + '/' + this.inetAddress.getHostAddress();
}
return "/" + this.inetAddress.getHostAddress();
}
Expand Down Expand Up @@ -1145,6 +1148,7 @@ protected final String setHostNameForClients(Properties networkProps) {
Attribute.HOSTNAME_FOR_CLIENTS, GfxdConstants.GFXD_PREFIX +
Attribute.HOSTNAME_FOR_CLIENTS, monitorlite);
if (host != null) {
this.hostNameForClients = host;
this.hostName = host;
return host;
}
Expand All @@ -1157,7 +1161,8 @@ protected final String setHostNameForClients(Properties networkProps) {
try {
final InetAddress localHost = SocketCreator.getLocalHost();
if (localHost != null && !localHost.isLoopbackAddress()) {
return (this.hostName = getHostFromInetAddress(localHost));
this.hostNameForClients = getHostFromInetAddress(localHost);
return (this.hostName = this.hostNameForClients);
}
} catch (UnknownHostException uhe) {
// ignored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public void testLocatorStartupAPI() throws Exception {
}
String netStr = rs.getString(3);
assertTrue("Unexpected network server address " + netStr,
netStr.endsWith("/0.0.0.0[" + netPort + ']'));
netStr.endsWith("[" + netPort + ']') && !netStr.contains("/0.0.0.0"));
assertFalse("expected no more than one row from SYS.MEMBERS", rs.next());
} finally {
try {
Expand Down

0 comments on commit 25ddfef

Please sign in to comment.