Picks the first reasonable looking IP address from network interfaces.
This should just work when running on a VPS, but also provides
so that when running in LAN you get the first reasonable looking LAN IP address.
More info: http://en.wikipedia.org/wiki/Private_network
Your laptop probably does not have a non-local IP address, but your VPS server probably does. This just returns the first address, which will probably be IPv4.
This module is based on the "ip" module.
The main export is a function
nonPrivateIP(interfaces, filter, details) where:
nullor a mock of
os.networkInterfaces(), typically this should be
filteris a function of the shape
(address, details) => booleanwhere
addressis the IP address as a string, and
detailsis the whole object with additional fields, e.g.
detailsis a boolean that controls whether you want the return of the function to be just the IP address as a string (
false, this is the default) or the whole object with additional fields (
// On a VPS: const nonPrivateIP = require('non-private-ip') nonPrivateIP() // 22.214.171.124
// In a LAN: const nonPrivateIP = require('non-private-ip') nonPrivateIP.private() // 192.168.0.101