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 🙏

© 2024 – Pkg Stats / Ryan Hefner

npr

v1.0.19

Published

A proxy server written in nodejs, supporting TCP in proxy mode, HTTP and Websocket in router mode.

Downloads

45

Readme

npr

A nodejs proxy server.

Supports TCP in proxy mode, HTTP and Websocket in router mode.

Installation

  • Standalone Installation (as command line utility):
    sudo npm install npr -g

  • Modular Installation (as a node module):
    sudo npm install npr

Startup (as command line utility)

  • Start the proxy server with default configuration npr.json:
    npr

  • Start the proxy server with selected configuration google.json:
    npr google.json

  • Start the proxy server with multiple configurations google.json ms.json:
    npr google.json ms.json

Use as node module

var npr = require('npr');

var configProxy1 = {
    "dstPort": 80,
    "localPort": 3000,
    "dstAddr": "www.microsoft.com"
};

var configProxy2 = {
    "dstPort": 80,
    "localPort": 2000,
    "dstAddr": "www.google.com"
};

var configRouter = {
    "localPort": 8000,
    "routes": {
        "hosta": {
            "dstAddr": "127.0.0.1",
            "dstPort": 10309
        },
        "default": {
            "dstAddr": "127.0.0.1",
            "dstPort": 10309
        }
    }
};

npr.run(configProxy1);
npr.run(configProxy2);
npr.run(configRouter);

Proxy mode

A configuration npr.json looks like this:

{
  "microsoft" : {
    "dstPort" : 80,
    "localPort" : 3000,
    "dstAddr" : "www.microsoft.com"
  },
  "google" : {
    "dstPort" : 80,
    "localPort" : 2000,
    "localAddr" : "127.0.0.1",
    "dstAddr" : "www.google.com"
  }
}

means that:
when the clients connect to 127.0.0.1:3000, they connect to www.microsoft.com:80, and when the clients connect to 127.0.0.1:2000, they connect to www.google.com:80.

Please note that localAddr is not necessary, when omitted, the server will listen on all network interfaces.

Router mode

Router mode works only with HTTP, not even HTTPS. Proxy mode and router mode can be working together happily. A configuration npr.json looks like this:

{
  "google_ms" : {
    "localPort" : 4000,
    "routes" : {
      "hostname_a" : {
        "dstAddr" : "www.microsoft.com",
        "dstPort" : 80
      },
      "hostname_b" : {
        "dstAddr" : "www.google.com",
        "dstPort" : 80
      },
      "default" : {
        "dstAddr" : "www.yahoo.com",
        "dstPort" : 80
      }
    }
  }
}

means that:
if multiple host names / domain names are bound to the proxy server, let's say hostname_a and hostname_b. When the clients connect to hostname_a:4000, they connect to www.microsoft.com:80, and when the clients connect to hostname_b:4000, they connect to www.google.com:80. If the clients connect to a host name which is not in the route table, 127.0.0.1:4000 from the proxy server itelf, for example, they connect to the default route www.yahoo.com:80.