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

haraka-net-utils

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haraka-net-utils

haraka network utilities

  • 1.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
increased by38.53%
Maintainers
4
Weekly downloads
 
Created
Source

CI Linux CI Windows Code Coverage Code Climate

NPM

Net-Utils

This module provides network utility functions.

Usage

const net_utils = require('haraka-net-utils');

ip_to_long

// Convert IPv4 to long
const long = net_utils.ip_to_long('11.22.33.44');  // 185999660

long_to_ip

// Convert long to IPv4
const ip = net_utils.long_to_ip(185999660);  // 11.22.33.44

dec_to_hex

// Convert decimal to hex
const hex = net_utils.dec_to_hex(20111104);  // 132df00

hex_to_dec

// Convert hex to decimal
const dec = net_utils.hex_to_dec('132df00');  // 20111104

is_local_ipv4

// Is IPv4 address on a local network?
net_utils.is_local_ipv4('127.0.0.200');   // true (localhost)
net_utils.is_local_ipv4('169.254.0.0');   // true (link local)
net_utils.is_local_ipv4('226.0.0.1');     // false

is_private_ipv4

// Is IPv4 address in RFC 1918 reserved private address space?
net_utils.is_private_ipv4('10.0.0.0');       // true
net_utils.is_private_ipv4('192.168.0.0');    // true
net_utils.is_private_ipv4('172.16.0.0');     // true

is_local_ipv6

// Is IPv6 addr on local network?
net_utils.is_local_ipv6('::1');           // true (localhost)
net_utils.is_local_ipv6('fe80::')         // true (link local)
net_utils.is_local_ipv6('fc00::')         // true (unique local)
net_utils.is_local_ipv6('fd00::')         // true (unique local)

is_private_ip

// determines if an IPv4 or IPv6 address is on a "private" network
// For IPv4, returns true if is_private_ipv4 or is_local_ipv4 are true
// For IPv6, returns true if is_local_ipv6 is true

is_local_host

Checks to see if a host name resolves to a local ip.

is_local_ip

Checks to see if an IP is bound locally or an IPv4 or IPv6 localhost address.

ip_in_list

// searches for 'ip' as a hash key in the list object or array
// ip can be a host, an IP, or an IPv4 or IPv6 range
net_utils.ip_in_list(object, ip);
net_utils.ip_in_list(array, ip);
net_utils.ip_in_list(tls.no_tls_hosts, '127.0.0.5');

get_mx

net_utils.get_mx(domain, (err, mxList) => {
    if (err)  // handle any errors
    for (const mx of mxList) {
        // do something with each mx
    }
})

Keywords

FAQs

Package last updated on 20 Dec 2021

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