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 🙏

© 2026 – Pkg Stats / Ryan Hefner

windows-network-interface-monitor

v1.0.1

Published

A utility to monitor a network interface on Windows for IP changes

Readme

windows-network-interface-monitor

Apache 2.0 License node.js 16+ Latest Release

This library provides the ability to monitor a network interface on Windows for IP changes.

Installation

It is recommended to use npm to install windows-network-interface-monitor:

npm install windows-network-interface-monitor

Note that the required package "ffi-napi" uses native modules and relies on "node-gyp" to build the project. As a result, there are some prerequisites that need to be installed/configured. Please refer to node-gyp's instructions.

Usage

First, find out the network interface to monitor for. The name should be obtained from the output of os.networkInterfaces(), and not from Windows command "ipconfig":

console.log(JSON.stringify(require('os').networkInterfaces(), null, 2));

For your convenience, a utility show-interfaces.js is provided. Just run "node lib/show-interfaces.js [ipv4|ipv6]" to find out the list of network interfaces and their assigned IP addresses. Sample output from "node lib/show-interfaces.js":

{
  "Ethernet": [
    {
      "address": "fe80::200:ff:fe00:0",
      "family": "IPv6"
    },
    {
      "address": "192.168.0.1",
      "family": "IPv4"
    }
  ],
  "Loopback Pseudo-Interface 1": [
    {
      "address": "::1",
      "family": "IPv6"
    },
    {
      "address": "127.0.0.1",
      "family": "IPv4"
    }
  ]
}

Pass this interface name as the first parameter in NetworkInterfaceMonitor's constructor. The second parameter is the address family to monitor for. Valid values are "IPv4", "IPv6", and "Any", which means both. The last parameter is the callback function. The monitor will pass 2 parameters to this callback:

  • address - This is an object that has monitored address families as properties and corresponding IP addresses as property values. For example, to get IPv4 address, use address.IPv4.
  • eventType - The type of event that triggered this notification. Defined values are:
    • NetworkInterfaceMonitor.EventType.Initial: initial callback when monitor is started. A convenient way to obtain current IP address.
    • NetworkInterfaceMonitor.EventType.IPChanged: when IP assigned to the network interface has changed.
    • NetworkInterfaceMonitor.EventType.IPAssigned: when an IP is assigned to the network interface. This usually happens when the network is activated, e.g. connecting to Wi-Fi or a VPN adapter.
    • NetworkInterfaceMonitor.EventType.IPRemoved: when previous IP assignment of the network interface is removed. This usually happens when the network is deactivated, e.g. disconnecting from Wi-Fi or a VPN adapter.

After instantiating a NetworkInterfaceMonitor, call start() on it to start the monitor.

When the monitor is no longer needed, make sure to call stop() to properly release the underlying handle obtained from Windows native API.

Example

const NetworkInterfaceMonitor = require('windows-network-interface-monitor');
const networkInterface = "Local Area Connection";
const addressFamily = "IPv4";

const monitor = new NetworkInterfaceMonitor(networkInterface, addressFamily, (address, eventType) => {
    switch (eventType) {
        case NetworkInterfaceMonitor.EventType.Initial:
            if (address !== null) {
                console.log(`Current address: ${address[addressFamily]}`);
            } else {
                console.log(`Network interface ${networkInterface} is inactive.`);
            }
            break;

        case NetworkInterfaceMonitor.EventType.IPChanged:
            console.log(`IP address changed: ${address[addressFamily]}`);
            break;

        case NetworkInterfaceMonitor.EventType.IPAssigned:
            console.log(`Network interface ${networkInterface} is now active.`);
            console.log(`IP address assigned: ${address[addressFamily]}`);
            break;

        case NetworkInterfaceMonitor.EventType.IPRemoved:
            console.log(`Network interface ${networkInterface} is now inactive.`);
            break;
    }
});
monitor.start();

// Wait for events here

// When monitor is no longer needed
monitor.stop();