Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

non-private-ip

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

non-private-ip

see if you have a non private (i.e. public ip address)

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
increased by2.42%
Maintainers
3
Weekly downloads
 
Created
Source

non-private-ip

Picks the first reasonable looking IP address from network interfaces. This should just work when running on a VPS, but also provides private APIs 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.

API

The main export is a function nonPrivateIP(interfaces, filter, details) where:

  • interfaces is either null or a mock of os.networkInterfaces(), typically this should be null
  • filter is a function of the shape (address, details) => boolean where address is the IP address as a string, and details is the whole object with additional fields, e.g. address, netmask, family, mac, cidr, etc
  • details is 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 (true)
// On a VPS:
const nonPrivateIP = require('non-private-ip')
nonPrivateIP() // 80.78.25.153
// In a LAN:
const nonPrivateIP = require('non-private-ip')
nonPrivateIP.private() // 192.168.0.101

License

MIT

FAQs

Package last updated on 26 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc