Skip to content

Instantly share code, notes, and snippets.

@TooTallNate

TooTallNate/getip.js

Forked from isaacs/getip.js
Created Oct 17, 2010
Embed
What would you like to do?
var child_process = require("child_process");
function getIPs (cb) {
child_process.exec("ifconfig -a", function (er, o) {
if (er) return cb(er);
cb(null, o.match(/inet (?:addr:)?([0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3})/g).map(function (i) {
return i.replace(/^inet (?:addr:)?/, '');
}));
})
}
getIPs(function (er, ips) {
console.error([er, ips]);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment