kopia lustrzana https://github.com/c9/core
display real ip instead of 0.0.0.0
rodzic
a53da8f95d
commit
469d58b34e
|
@ -93,7 +93,7 @@ module.exports = function(config, optimist) {
|
|||
if (!/:/.test(argv.auth) && !isLocalhost) {
|
||||
console.log("Authentication is required when not running on localhost.\nPlease use -a user:pass or --listen localhost to listen locally.");
|
||||
console.log("switching to localhost");
|
||||
host == "127.0.0.1";
|
||||
host = config.host = "127.0.0.1";
|
||||
}
|
||||
var auth = (argv.auth || ":").split(":");
|
||||
|
||||
|
@ -102,7 +102,8 @@ module.exports = function(config, optimist) {
|
|||
packagePath: "connect-architect/connect",
|
||||
port: port,
|
||||
host: host,
|
||||
websocket: true
|
||||
websocket: true,
|
||||
showRealIP: !config.mode
|
||||
},
|
||||
{
|
||||
packagePath: "connect-architect/connect.basicauth",
|
||||
|
|
|
@ -127,7 +127,10 @@ module.exports = function startup(options, imports, register) {
|
|||
if (err)
|
||||
return register(err);
|
||||
|
||||
console.log("Connect server listening at " + proto + "://" + host + ":" + port);
|
||||
console.log("Connect server listening at " + proto + "://"
|
||||
+ (host == "0.0.0.0" && options.showRealIP
|
||||
? getLocalIPs()[0]
|
||||
: host) + ":" + port);
|
||||
|
||||
register(null, {
|
||||
"onDestruct": function(callback) {
|
||||
|
@ -210,6 +213,22 @@ module.exports = function startup(options, imports, register) {
|
|||
|
||||
return handle;
|
||||
}
|
||||
|
||||
function getLocalIPs() {
|
||||
var os = require("os");
|
||||
|
||||
var interfaces = os.networkInterfaces ? os.networkInterfaces() : {};
|
||||
var addresses = [];
|
||||
for (var k in interfaces) {
|
||||
for (var k2 in interfaces[k]) {
|
||||
var address = interfaces[k][k2];
|
||||
if (address.family === "IPv4" && !address.internal) {
|
||||
addresses.push(address.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
};
|
||||
|
||||
function merge(objects) {
|
||||
|
|
Ładowanie…
Reference in New Issue