Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-1723 JMX Connector bind on all network interfaces #1750

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates]

package org.glassfish.admin.mbeanserver;

import org.glassfish.hk2.api.ServiceLocator;
Expand Down Expand Up @@ -77,8 +78,10 @@ public JMXServiceURL getJMXServiceURL() {
}

public String hostname() throws UnknownHostException {
if (mHostName.equals("") || mHostName.equals("0.0.0.0")) {
if (mHostName.equals("")) {
return Util.localhost();
} else if (mHostName.equals("*")) {
return "0.0.0.0";
} else if (mHostName.contains(":") && !mHostName.startsWith("[")) {
return "["+mHostName+"]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates]

package org.glassfish.admin.mbeanserver;

import java.io.File;
Expand Down Expand Up @@ -137,7 +139,7 @@ public RMIConnectorStarter(
}

final boolean ENABLED = true;
mBindToSingleIP = ENABLED && !(address.equals("0.0.0.0") || address.equals(""));
mBindToSingleIP = ENABLED && !(address.equals("0.0.0.0") || address.equals("*")|| address.equals(""));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems like it should work, but for whatever reason when it should be binding multiple IPs it still doesn't. Possibly due to the logic on line 160.

Copy link
Contributor Author

@jGauravGupta jGauravGupta Jul 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it does not listens on 0.0.0.0 ? I tested with CurrPort tool.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port is correctly opened when scanning over nmap and port scanning tools, but actually connecting over JMX will fail


final InetAddress inetAddr = getAddress(address);

Expand Down Expand Up @@ -181,8 +183,9 @@ private static InetAddress getAddress(final String addrSpec)
String actual = addrSpec;
if (addrSpec.equals("localhost")) {
actual = "127.0.0.1";
} else if (addrSpec.equals("*")) {
actual = "0.0.0.0";
}

final InetAddress addr = InetAddress.getByName(actual);
return addr;
}
Expand All @@ -204,10 +207,6 @@ private static void restoreRMIHostname(final String saved,
}
}

private static void debug(final Object o) {
System.out.println("" + o);
}

/**
* Starts the RMI Registry , where the RMIServer would be exported. If this
* is a multihomed machine then the Registry is bound to a specific IP address
Expand Down Expand Up @@ -274,7 +273,7 @@ public JMXConnectorServer start() throws MalformedURLException, IOException, Unk

final String name = "jmxrmi";
final String hostname = hostname();
final Map<String, Object> env = new HashMap<String, Object>();
final Map<String, Object> env = new HashMap<>();

env.put("jmx.remote.jndi.rebind", "true");

Expand Down