Created
March 3, 2016 17:29
-
-
Save theaccordance/27c1058850e715ef52e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'); | |
| function getLocalIp() { | |
| var interfaces = os.networkInterfaces(), | |
| address = ''; | |
| for (var k in interfaces) { | |
| for (var k2 in interfaces[k]) { | |
| var intf = interfaces[k][k2]; | |
| if (intf.family == 'IPv4' && !intf.internal) { | |
| address = intf.address; | |
| } | |
| } | |
| } | |
| return address; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment