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

network

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

network

Cross platform network utilities for Node.js (gateway_ip, MAC address, etc)

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
64K
decreased by-2.08%
Maintainers
1
Weekly downloads
 
Created
Source

Network Utilies for Node.js

Install

$ npm install network

Usage

Get public IP

Returns your public IP address, as reported by DynDNS.org.

var network = require('network');
network.get_public_ip(function(err, ip) {
  console.log(err || ip); // should return your public IP address
})

Get private IP

Returns the IP address assigned to your first active network inteface.

network.get_private_ip(function(err, ip) {
  console.log(err || ip); // err may be 'No active network interface found'.
})

Get gateway IP

Returns the IP address assigned to your first active network inteface.

network.get_gateway_ip(function(err, ip) {
  console.log(err || ip); // err may be 'No active network interface found.'
})

Get active interface

Returns the IP address, MAC address and gateway IP address for the active network interface.

network.get_active_interface(function(err, obj) {

  /* obj should be:

  { name: 'eth0',
    ip_address: '10.0.1.3',
    mac_address: '56:e5:f9:e4:38:1d',
    type: 'Wired',
    netmask: '255.255.255.0',
    gateway_ip: '10.0.1.1' }

  */
})

Get interfaces list

Returns list of network interfaces, including MAC addresses and the such, just as in the example above.

network.get_interfaces_list(function(err, list) {

  /* list should be:

  [{
    name: 'eth0',
    ip_address: '10.0.1.3',
    mac_address: '56:e5:f9:e4:38:1d',
    type: 'Wired',
    netmask: '255.255.255.0',
    gateway_ip: '10.0.1.1'
   },
   { ... }, { ... }]

  */
})

Written by Tomás Pollak. Copyright (c) 2014 Fork, Ltd.

License

MIT.

FAQs

Package last updated on 30 Sep 2014

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