Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save suncn/3ebd79318ee5a0903a445aae82be7a4f to your computer and use it in GitHub Desktop.
Save suncn/3ebd79318ee5a0903a445aae82be7a4f to your computer and use it in GitHub Desktop.
atom-live-server locaip
var os=require('os'),
iptable={},
ifaces=os.networkInterfaces();
for (var dev in ifaces) {
ifaces[dev].forEach(function(details,alias){
if ((details.family=='IPv4') && (details.internal == false)) {
// iptable[dev+(alias?':'+alias:'')]=details.address;
iptable['localIP'] = details.address;
}
});
}
var address = server.address();
var serveHost = address.address === "0.0.0.0" ? iptable.localIP : address.address;
var openHost = host === "0.0.0.0" ? iptable.localIP : host;
var serveURL = protocol + '://' + serveHost + ':' + address.port;
var openURL = protocol + '://' + openHost + ':' + address.port;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment