Skip to content

Commit

Permalink
Restricting the host where grid hub is listening if -host option is s…
Browse files Browse the repository at this point in the history
…pecified. Fixes issue 4589
  • Loading branch information
barancev committed Dec 24, 2013
1 parent 2262635 commit 71c5e23
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions java/server/src/org/openqa/grid/web/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class Hub {

private final int port;
private final String host;
private final boolean isHostRestricted;
private final Registry registry;
private final Map<String, Class<? extends Servlet>> extraServlet = Maps.newHashMap();

Expand All @@ -77,9 +78,11 @@ public Hub(GridHubConfiguration config) {

if (config.getHost() != null) {
host = config.getHost();
isHostRestricted = true;
} else {
NetworkUtils utils = new NetworkUtils();
host = utils.getIp4NonLoopbackAddressOfThisMachine().getHostAddress();
isHostRestricted = false;
}
this.port = config.getPort();

Expand All @@ -101,6 +104,9 @@ private void initServer() {
server = new Server();
SocketConnector socketListener = new SocketConnector();
socketListener.setMaxIdleTime(60000);
if (isHostRestricted) {
socketListener.setHost(host);
}
socketListener.setPort(port);
server.addConnector(socketListener);

Expand Down

0 comments on commit 71c5e23

Please sign in to comment.