Last active
August 29, 2015 14:02
-
-
Save drugoi/b1f9424b0f9cd86d0ff2 to your computer and use it in GitHub Desktop.
Get current ip in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os'); | |
var ifaces = os.networkInterfaces(); | |
for (var dev in ifaces) { | |
var alias = 0; | |
ifaces[dev].forEach(function(details) { | |
if (details.family == 'IPv4') { | |
if (details.address == '127.0.0.1') { | |
return; | |
} | |
++alias; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment