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

netkit

v0.0.5

Published

Network utility kit

Readme

node-netkit

![Gitter](https://badges.gitter.im/Join Chat.svg)

node module for network interface & routing manipulation

work in progress:

  • only supports Linux so far
  • IPv4 support largely untested yet
  • rapidly changing. not for production unless you really know what you're doing.

API

  • TUN/TAP device creation support w/ stream interface
  • update routing tables
  • interface up / down
  • more to come

Bear in mind, most of the time you need to be root / sudo to run these commands.

Right now the code is the documentation...

/**
 * test tun interface
 */


var netkit = require('../index.js');

var util = require('util');

var tun0 = netkit.newTunInterfaceRaw();

tun0.ifname = "tun_test";

if(tun0.create()) {
	console.log("Interface created: " + tun0.ifname);
	console.log("    fd: " + tun0.fd);
	setTimeout(function(){
		if(tun0.open()) {
			console.log("Opened successfully.");
			netkit.assignAddress({
				ifname:tun0.ifname,         // required
				mtu: 1501,                  // test MTU - set it bigger than default
				inet6: {
					addr: "fe80::1",        // assign a single IP
//					mask: "0:0:0:FC00:0:0:0:0"
					add_addr: [ "aaaa::1/64" ] // assign multiple IPs. Also hand just a string: "aaaa::1"

				}
			},function(err){
				if(err) {
					console.log("Error: " + util.inspect(err));
				} else {
					console.log("assignAddress called successfully.");
				}
			});
			netkit.assignRoute({
				add_route6: 
					[  // ipv6 routes: dest
						{ 
						  dest: "2003::/16",        // ip -6 route add 2003::/16 dev tun_test
						  via_if: "tun_test",       // via the interface 'tun_test'
//						  via_network: "2001::/16", 
						  metric: 2400,
						  flags: netkit.FLAGS.RT_MODIFIED | netkit.FLAGS.RT_DYNAMIC  // netkit.FLAGS.RT_GATEWAY | 
						}
					],
				del_route6: []
			},function(err){
				if(err) {
					console.log("Error: " + util.inspect(err));
				} else {
					console.log("assignRoute called successfully.");
				}				
			});
			netkit.setIfFlags(tun0.ifname,netkit.FLAGS.IFF_UP | netkit.FLAGS.IFF_RUNNING); // turn the interface up

			tun0.stream.on('readable', function() {
				var chunk;
				while (null !== (chunk = tun0.stream.read())) {
					console.log('got %d bytes of data', chunk.length);
					console.log('buffer: ' + chunk.toJSON());
					if(!tun0.stream.write(chunk)) {
						console.log("ERROR: test write failed");
					} else
					    console.log("wrote back " + chunk.length + " bytes.");
				}
			});

			setTimeout(function(){
			netkit.assignRoute({
				del_route6: 
					[  // ipv6 routes: dest
						{ 
						  dest: "2003::/16",        // ip -6 route add 2003::/16 dev tun_test
						  via_if: "tun_test",       // via the interface 'tun_test'
//						  via_network: "2001::/16", 
						  metric: 2400,             // if you have a specific metric in add_route6 you will need to use the same metric so the 
						                            // kernel can find the correct route
						  flags: netkit.FLAGS.RT_GATEWAY | netkit.FLAGS.RT_MODIFIED | netkit.FLAGS.RT_DYNAMIC
						}
					]
				});
		    }, 5000);
		}
	},1000);
} else {
	console.log("Failed to create interface tun0, error: " + tun0.lastError + " --> " + tun0.lastErrorStr);
}

console.log("You can type 'ifconfig -a' in a terminal to see if the interface exists.");

setTimeout(function(){
	console.log("done.");
	// turn down the interface...
//	netkit.unsetIfFlags(tun0.ifname,network.FLAGS.IFF_UP | network.FLAGS.IFF_RUNNING);
}, 15000);