Skip to content

Commit a0b2e56

Browse files
committed
adding 'listen' param
1 parent d641916 commit a0b2e56

10 files changed

Lines changed: 412 additions & 333 deletions

File tree

cli-options/opts.start.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
"host": {
9999
"desc": "Specify a hostname to use"
100100
},
101+
"listen": {
102+
"desc": "Specify a hostname bind to (this will prevent binding to all interfaces)"
103+
},
101104
"logLevel": {
102105
"desc": "Set the logger output level (silent, info or debug)"
103106
},

lib/async.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
socketPort = bs.options.getIn(["socket", "port"]);
6363
}
6464

65-
utils.getPort(socketPort, null, function(err, port) {
65+
utils.getPort(bs.options.get("listen", "localhost"), socketPort, null, function(err, port) {
6666
if (err) {
6767
return utils.fail(true, err, bs.cb);
6868
}
@@ -286,7 +286,18 @@ module.exports = {
286286
);
287287
}
288288

289-
return ui(uiOpts.toJS(), bs, function(err, ui) {
289+
/**
290+
* Append the 'listen' option
291+
*/
292+
const opts = uiOpts.update(uiOpts => {
293+
const listen = bs.options.get('listen');
294+
if (listen) {
295+
return uiOpts.set("listen", listen);
296+
}
297+
return uiOpts;
298+
});
299+
300+
return ui(opts.toJS(), bs, function(err, ui) {
290301
if (err) {
291302
return done(err);
292303
}

lib/default-config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,13 @@ module.exports = {
473473

474474
/**
475475
* Specify a host to listen on. Use this if you want to
476-
* prevent binding to all interfaces
476+
* prevent binding to all interfaces.
477+
*
478+
* Note: When you specify this option, it overrides the 'host' option
477479
* @property listen
478480
* @type String
479-
* @default null
481+
* @default undefined
480482
*/
481-
listen: null,
482483

483484
/**
484485
* Support environments where dynamic hostnames are not required

lib/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports.plugin = function(bs) {
3434
/**
3535
* Listen on the available port
3636
*/
37-
bsServer.server.listen(bs.options.get("port"));
37+
bsServer.server.listen(bs.options.get("port"), bs.options.get("listen"));
3838

3939
/**
4040
* Hack to deal with https://github.com/socketio/socket.io/issues/1602#issuecomment-224270022

lib/utils.js

Lines changed: 0 additions & 317 deletions
This file was deleted.

0 commit comments

Comments
 (0)