Created
July 2, 2014 13:24
-
-
Save JosePedroDias/76e477396c48d03c0a2f to your computer and use it in GitHub Desktop.
returns object with network interface name -> IP address
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 getMyIPs = function() { | |
var ips = {}; | |
var ifaces = os.networkInterfaces(); | |
var onDetails = function(details) { | |
if (details.family === 'IPv4') { | |
ips[ dev ] = details.address; | |
} | |
}; | |
for (var dev in ifaces) { | |
ifaces[dev].forEach(onDetails); | |
} | |
return ips; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment