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

wstun

v0.1.6

Published

A set of tools to establish TCP tunnels (or TCP reverse tunnels) over WebSocket connections for circumventing the problem of directly connect to hosts behind a strict firewall or without public IP. It also supports WebSocket Secure (wss) connections.

Downloads

2

Readme

WSTUN - Modified for Data Gateway Server and Data Gateway Client (for internal use)

Overview

See readme of @mdslab/wstun

Installation (for debug)

  1. Download source code and go to the root directory.
  2. Run npm install to install all dependencies.
  3. Run npm link to expose wstun cmd globally.

Installation

npm install wstun

Programmatic Usage

Instantiation of a reverse tunnel server

var wstun = require("wstun");

// without security
reverse_server = new wstun.server_reverse();

// or with security (<PRIVATE-KEY-PATH> and <PUBLIC-KEY-PATH> are the paths of the private and public keys in .pem formats)
reverse_server = new wstun.server_reverse({ssl:true, key:"<PRIVATE-KEY-PATH>", cert:"<PUBLIC-KEY-PATH>"});

//start the server (<PORT> is the listening port)
reverse_server.start(<PORT>);

Implementation of a reverse tunnel client

var wstun = require("wstun");

reverse_client = new wstun.client_reverse();

// without security
wstunHost = 'ws://wstunServerIP:wstunPort';

// or with security 
wstunHost = 'wss://wstunServerIP:wstunPort';

// <publicPort> is the port on the reverse tunnel server on which the tunneled service will be reachable
// <remoteHost>:<remotePort> is the endpoint of the service to be reverse tunneled
reverse_client.start(<publicPort>, wstunHost, '<remoteHost>:<remotePort>', {
    token: '',
    trayId: '',
    trayName: ''
}, {
    success: function(){},
    failure: function(error){}
});

Command-Line Usage

Data Gateway Server

// start server
wstun -r -s 8080

1. Get token

GET http://localhost:8080/token

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 38
ETag: W/"26-OnijoHwIHbgqooKaIW/fxvGiQAA"
Date: Wed, 08 Jul 2020 04:23:28 GMT
Connection: keep-alive

"95d9b8e6-39fb-46cd-a401-7d7f9119f710"

2. Get list of registered trays

GET http://localhost:8080/trays

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 2
ETag: W/"2-l9Fw4VUO7kr8CvBlt4zaMCqXZ0w"
Date: Wed, 08 Jul 2020 04:34:35 GMT
Connection: keep-alive

[{"id": "test","name": "test"}]

3. request available port

POST http://localhost:8080/availableport

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 81
ETag: W/"51-fs6jVncwj5ob5fovjIPuxuKIycQ"
Date: Wed, 08 Jul 2020 04:39:39 GMT
Connection: keep-alive

{
  "port": 57255,
  "token": "95d9b8e6-39fb-46cd-a401-7d7f9119f710"
}

4. Request available port with optional parameters (trayId, range)

POST http://localhost:8080/availableport

{"trayId":"test", "range": [3000,3100]}

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 81
ETag: W/"51-aZoi+f6MfcSHUwlYvJl2coUBQnY"
Date: Wed, 08 Jul 2020 04:37:06 GMT
Connection: keep-alive

{
  "port": 3000,
  "token": "95d9b8e6-39fb-46cd-a401-7d7f9119f710",
  "trayPort": "3306"
}

5. Close ws tunnel by port

DELETE http://localhost:8080/ws/3306

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 64
ETag: W/"40-IjZVx+QRCNTrAi8IdDEvyRt4MR0"
Date: Wed, 08 Jul 2020 04:41:21 GMT
Connection: keep-alive

"Web socket tunnel related to port 3306 is closed successfully."

Data Gateway Client

// create a ws tunnel to server with token
wstun -r3306:10.197.34.164:3306 ws://localhost:8080 --token=95d9b8e6-39fb-46cd-a401-7d7f9119f710

// client(tray service) creates a ws tunnel and register itself
wstun -r3306:10.197.34.164:3306 ws://localhost:8080 --token=95d9b8e6-39fb-46cd-a401-7d7f9119f710 --trayid=test --trayname=test