npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

net-toolkit.js

v1.2.0

Published

Network-tools for nodeJS

Readme

Net-Toolkit.js

Collection of Tools for Network interaction

Quickstart

// import Net-Toolkit
const netJS = require('net-toolkit.js');

// starting async function
async function start () {

    // we want to get our local ipv4 address
    console.log( await netJS.getLocalIpv4() );

    // we want to check if it's the localhost
    console.log( await netJS.isLocalhost(await netJS.getLocalIpv4()) );

    // we want to get all connected client in the local networks and their open ports (within a range of 0 to 100) with a timeout of a 1000 milliseconds
    console.log( await netJS.getOpenPortsOnLocalNetworkInRange( 0, 100, 1000) );
}

// let's start the function
start();

Documentation

Please note, that the functions are asynchronous or return a promise

getLocalIpv4

With this function you can get the ipv4 address of the local machine

    const localIpv4 = await netJS.getLocalIpv4();

getLocalIpv6

With this function you can get the ipv6 address of the local machine

    const localIpv6 = await netJS.getLocalIpv6();

getLocalIpv4s

With this function you can get an array of ipv4 adresses of the local machine

    const localIpv4s = await netJS.getLocalIpv4s();

getLocalIpv6s

With this function you can get an array of ipv6 adresses of the local machine

    const localIpv6s = await netJS.getLocalIpv6s();

getLocalIpv4AndIpv6

With this function you can get an object containing the ipv4 and ipv6 addresses

    const adressObjects = await netJS.getLocalIpv4AndIpv6();

getExternalIpv4

With this funcion you can get the external ipv4 address of the local machine

    const externalIpv4 = await netJS.getExternalIpv4();

getExternalIpv6

With this funcion you can get the external ipv6 address of the local machine

    const externalIpv6 = await netJS.getExternalIpv6();

isConnected

With this function you can check if the local machine is connected to the internet

    const isConnected =  await netJS.isConnected();

checkHttp

With this function you can check if a special ipAdress is reachable with http on given port

    const httpCheck = await netJS.checkHttp(ip, port);

checkWs

With this function you can check if a special ipAdress is reachable with webSocket on given ports

    const wsCheck = await netJS.checkWs(ip, port);

getIpArrayFromHostname

With this function you can get an array of Objects containing IP address and belonging family from a hostname by looking up on the dns

    const ips = getIpArrayFromHostname(hostname);
    /*
        Out for 'google.com' as hostname
        { address: '142.250.185.78', family: 4 },
        { address: '2a00:1450:4001:80e::200e', family: 6 }
    */

getIpv4FromHostname

With this function you can get the Ipv4 adress from a hostname by looking up on the dns

    const ip = getIpv4FromHostname(hostname);

getIpv6FromHostname

With this function you can get the Ipv6 address from a hostname by looking up on the dns

    const ip = getIpv4FromHostname(hostname);

getIpv4FromIpv6

With this function you can get the Ipv4 adress from an ipv6 adress by looking up in the dns

    const ipv4 = await netJS.getIpv4FromIpv6(ipv6);

getIpv6FromIpv4

With this function you can get the Ipv6 adress from an ipv6 adress by looking up in the dns

    const ipv6 = await netJS.getIpv6FromIpv4(ipv4);

getHostnameFromIpv4

With this function you can get the Ipv6 adress from an ipv4 adress by looking up in the dns

    const hostname = await netJS.getHostnameFromIpv4(ipv4);

getHostnameFromIpv6

With this function you can get the Ipv6 adress from an ipv6 adress by looking up in the dns

    const hostname = await netJS.getHostnameFromIpv6(ipv6);

getMacAdresses

With this function you can get an Array of Mac Adresses

    const macAdresses = await netJS.getMacAdresses();

getAllIpv4Adresses

With this function you can get an Array of all possible Ipv4 Adresses

    const allIpv4Adresses = await netJS.getAllIpv4Adresses(ipv4);

getDevices

With this function you can get an Array of all devices connected to the local network

    const devices = await netJS.getDevices(timeout);

getGateways

With this function you can get an array of all the gateways connected to the typical local network

    const gateways = await netJS.getGateways();

getNetmasks

With this function you can get an array of all the netmasks of the connected local networks

    const netmasks = await netJS.getNetmasks();

pingIp

With this function you can ping an ip adress

    const ping = netJS.ping(ip, timeout)

checkPingIp

With this function you can check if an ip adress is reachable

    const ping = await netJS.checkPingIp(ip, timeout)

isLocalhost

With this function you can check if an ip adress is localhost

    const localhost = await netJS.isLocalhost(ip)

getLocalIpAdressesWithSpecifiedOpenPort

With this function you can get an array of all local ip adresses with specified open port

    const localIpAdressesWithSpecifiedOpenPort = await netJS.getLocalIpAdressesWithSpecifiedOpenPort(port)

getOpenPortsOfIpInRange

With this function you can get an array of all open ports of an ip adress in range

    const openPortsOfIpInRange = await netJS.getOpenPortsOfIpInRange(ip, startPort, endPort, timeout);

getOpenPortsOfIp

With this function you can get an array of all open ports of an ip adress

    const openPortsOfIp = await netJS.getOpenPortsOfIp(ip, timeout)

getOpenPortsOnLocalNetworkInRange

With this function you can get an array of all open ports of the local network in range and the belonging ip adresses

    const openPortsOnLocalNetworkInRange = await netJS.getOpenPortsOnLocalNetworkInRange(startPort, endPort, timeout)

getOpenPortsOnLocalNetwork

With this function you can get an array of all open ports of the local network and the belonging ip adresses

    const openPortsOnLocalNetwork = await netJS.getOpenPortsOnLocalNetwork(timeout)

getLocalNetworkCidr

With this function you can get all the local network cidr

    const localNetworkCidr = await netJS.getLocalNetworkCidr()

Future support


Changelog

v.1.2.0

  • fixed bug again :(

v1.1.6

  • fixed Documentation
  • hopefully fixed all stuff

v1.1.5

  • fixed Documentation
  • fixed isLocalhost
  • changed ip family, because it didnt worked properly for me, because somewhat idk

v1.1.4

  • finally fixed the fixed non working imports
  • fixed stuff in documentation

v1.1.2

  • fixed documentation
  • fixed isLocalhosts
  • fixed import

v1.1.1

  • reverted to require
  • added future list

v1.1.0

  • fixed documentation

v1.0.9

  • added v to changelog v1.0.7

v1.0.8

  • changed to module.exports

v1.0.7

  • Changed from require to import
  • added Documentation for all functions
  • added getting array of local ip Adresses (ipv4 and ipv6)
  • added check if ping is possible
  • fixed typo