Skip to content

Commit

Permalink
adding 'listen' param
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Sep 17, 2018
1 parent d641916 commit a0b2e56
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 333 deletions.
3 changes: 3 additions & 0 deletions cli-options/opts.start.json
Expand Up @@ -98,6 +98,9 @@
"host": {
"desc": "Specify a hostname to use"
},
"listen": {
"desc": "Specify a hostname bind to (this will prevent binding to all interfaces)"
},
"logLevel": {
"desc": "Set the logger output level (silent, info or debug)"
},
Expand Down
15 changes: 13 additions & 2 deletions lib/async.js
Expand Up @@ -62,7 +62,7 @@ module.exports = {
socketPort = bs.options.getIn(["socket", "port"]);
}

utils.getPort(socketPort, null, function(err, port) {
utils.getPort(bs.options.get("listen", "localhost"), socketPort, null, function(err, port) {
if (err) {
return utils.fail(true, err, bs.cb);
}
Expand Down Expand Up @@ -286,7 +286,18 @@ module.exports = {
);
}

return ui(uiOpts.toJS(), bs, function(err, ui) {
/**
* Append the 'listen' option
*/
const opts = uiOpts.update(uiOpts => {
const listen = bs.options.get('listen');
if (listen) {
return uiOpts.set("listen", listen);
}
return uiOpts;
});

return ui(opts.toJS(), bs, function(err, ui) {
if (err) {
return done(err);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/default-config.js
Expand Up @@ -473,12 +473,13 @@ module.exports = {

/**
* Specify a host to listen on. Use this if you want to
* prevent binding to all interfaces
* prevent binding to all interfaces.
*
* Note: When you specify this option, it overrides the 'host' option
* @property listen
* @type String
* @default null
* @default undefined
*/
listen: null,

/**
* Support environments where dynamic hostnames are not required
Expand Down
2 changes: 1 addition & 1 deletion lib/server/index.js
Expand Up @@ -34,7 +34,7 @@ module.exports.plugin = function(bs) {
/**
* Listen on the available port
*/
bsServer.server.listen(bs.options.get("port"));
bsServer.server.listen(bs.options.get("port"), bs.options.get("listen"));

/**
* Hack to deal with https://github.com/socketio/socket.io/issues/1602#issuecomment-224270022
Expand Down
317 changes: 0 additions & 317 deletions lib/utils.js

This file was deleted.

0 comments on commit a0b2e56

Please sign in to comment.