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

js2ray

v3.0.5

Published

The v2ray vmess protocol, based on nodejs javascript which you can use on hosts and servers

Downloads

22

Readme

js2ray

A Node.js implementation of the V2Ray VMess protocol (plus other protocols like SOCKS and Freedom). Deployable on cPanel Node.js hosts and dedicated servers.

Install & Run

Install with:

npm i js2ray

Then create a file at /root/js2ray/index.js:

var js2ray = require("js2ray");
// your config here

Run as a systemd service:

systemctl enable js2ray
systemctl restart js2ray

It will stay alive forever.

Debug Mode

Stop the systemd service:

systemctl disable js2ray
systemctl stop js2ray

Then run manually for debugging:

node /root/js2ray/index.js

Setup

Server-side

var js2ray = require("js2ray");

var config = {
    inbounds: [
        {
            protocol: "vmess",
            networks: [
                {
                    type: "http", // ws | tcp | http | xhttp
                    address: "0.0.0.0",
                    port: 80,
                    option: {
                        path: "/ws",
                        fake: "hello world"
                    },
                }
            ],
            users: [
                {
                    id: "b87cd5bc-71d1-e7c7-e031-24390995a198",
                    security: "none", // auto | aes-128-gcm | chacha20-poly1305 | none | zero
                    alterId: 0,
                }
            ],
        },
        {
            protocol: "socks",
            networks: [
                {
                    address: "0.0.0.0",
                    port: 1080
                }
            ]
        }
    ],
    debug: function (...e) {
        // console.log(...e)
    },
    storage: __dirname + "/app.json",
}

js2ray.config(config).start();

Client / Bridge Side (Tunnel)

var js2ray = require("js2ray");

var config = {
    inbounds: [
        {
            protocol: "vmess",
            networks: [
                {
                    type: "http", // ws | tcp | http | xhttp
                    address: "0.0.0.0",
                    port: 80,
                    option: {
                        path: ["/", "/data"],
                        fake: "hello world"
                    },
                }
            ],
            users: [
                {
                    id: "b87cd5bc-71d1-e7c7-e031-24390995a155",
                    security: "none",
                    alterId: 0,
                }
            ],
        },
        {
            protocol: "socks",
            networks: [
                {
                    address: "0.0.0.0",
                    port: 1080
                }
            ]
        }
    ],
    outbounds: [
        {
            tag: "outbound",
            protocol: "vmess",
            networks: [
                {
                    type: "tcp",
                    address: "server.address",
                    port: 1234
                }
            ],
            users: [
                {
                    id: "b87cd5bc-71d1-e7c7-e031-24390995a198",
                    security: "none",
                    alterId: 0,
                }
            ],
        }
    ],
    storage: __dirname + "/app.json",
    debug: function (...e) {
        // console.log(...e)
    },
}

js2ray.config(config).start();

API-Enabled Server

You can leave users: [] and instead manage them remotely via the api field.

var js2ray = require("js2ray");
var fs = require("fs");
var os = require("os");

var config = {
    inbounds: [
        {
            protocol: "vmess",
            networks: [
                {
                    type: "http",
                    address: "0.0.0.0",
                    port: 80,
					ip: ["1.1.1.1"] // limit clients ip 
                    option: {
                        path: "/ws",
                        fake: "hello world"
                    },
                }
            ],
            users: []
        },
        {
            protocol: "socks",
            networks: [
                {
                    address: "0.0.0.0",
                    port: 1080,
					ip: ["1.1.1.1"] // limit clients ip 
                }
            ]
        }
    ],
    api: {
        address: "0.0.0.0",
        port: 2050,
        post: {
            task: function () {
                return JSON.stringify({
                    rmx: Math.round(os.totalmem() / 1024 / 1024),
                    ram: Math.round(os.freemem() / 1024 / 1024),
                    net: 0 // placeholder
                })
            },
            backup: function () {
                return fs.readFileSync(__dirname + "/app.json", "utf-8");
            }
        }
    },
    storage: __dirname + "/app.json",
    debug: function (...e) {
        // console.log(...e)
    },
}

js2ray.config(config).start();

SOCKS Examples

Minimal SOCKS Proxy with Freedom

var js2ray = require("js2ray");

var config = {
    inbounds: [
        {
            protocol: "socks",
            networks: [
                {
                    address: "0.0.0.0",
                    port: 10805,
                }
            ]
        }
    ],
    // if outbounds not defined, "freedom" is used by default
    storage: __dirname + "/app.json",
}

js2ray.config(config).start();

SOCKS-to-SOCKS Tunnel (SOCKS Inbound + SOCKS Outbound)

var js2ray = require("js2ray");

var config = {
    inbounds: [
        {
            protocol: "socks",
            networks: [
                {
                    address: "0.0.0.0",
                    port: 1080,
                }
            ],
			users: [
				{
					user: "u",
					pass: "p",
				}
			],
        }
    ],
    outbounds: [
        {
            protocol: "socks",
            networks: [
                {
                    address: "remote.socks.server",
                    port: 1080,
                }
            ],
			users: [
				{
					user: "server-u",
					pass: "server-p",
				}
			],
        }
    ],
    storage: __dirname + "/app.json",
}

js2ray.config(config).start();

License