Permalink
Browse files

Merge pull request #82 from lognormal/listen_host

listen on a specific interface
  • Loading branch information...
2 parents d011040 + 0c47446 commit b541de3ccafa53b26bd4b4e5da1cc66d1f47d8e8 @dannycoates dannycoates committed May 30, 2012
Showing with 13 additions and 3 deletions.
  1. +9 −0 bin/inspector.js
  2. +2 −1 config.json
  3. +2 −2 lib/debug-server.js
View
@@ -14,6 +14,9 @@ process.argv.forEach(function (arg) {
case '--web-port':
options.webPort = parseInt(parts[1], 10);
break;
+ case '--web-host':
+ options.webHost = (parts[1] && parts[1] !== 'null') ? parts[1] : null;
+ break;
default:
console.log('unknown option: ' + parts[0]);
break;
@@ -46,12 +49,18 @@ fs.readFile(path.join(__dirname, '../config.json'), function(err, data) {
if (!config.webPort) {
config.webPort = 8080;
}
+ if (!config.webHost) {
+ config.webHost = null; // null implies listen on all interfaces
+ }
if (!config.debugPort) {
config.debugPort = 5858;
}
if (options.webPort) {
config.webPort = options.webPort;
}
+ if (options.webHost) {
+ config.webHost = options.webHost;
+ }
debugServer = new DebugServer();
debugServer.on('close', function () {
View
@@ -1,6 +1,7 @@
{
"webPort": 8080,
+ "webHost": null,
"debugPort": 5858,
"saveLiveEdit": false,
"hidden": []
-}
+}
View
@@ -48,7 +48,7 @@ function handleWebSocketConnection(socket) {
function handleServerListening() {
console.log(
- 'visit http://0.0.0.0:' +
+ 'visit http://' + (config.webHost || '0.0.0.0') + ':' +
config.webPort +
'/debug?port=' + config.debugPort + ' to start debugging');
}
@@ -68,7 +68,7 @@ DebugServer.prototype.start = function(options) {
ws.sockets.on('connection', handleWebSocketConnection);
this.wsServer = ws;
httpServer.on('listening', handleServerListening);
- httpServer.listen(config.webPort);
+ httpServer.listen(config.webPort, config.webHost);
}
DebugServer.prototype.close = function() {

0 comments on commit b541de3

Please sign in to comment.