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

@sansamour/node-socks

v1.1.5

Published

A simple SOCKS/HTTP/HTTPS proxy implementation

Downloads

11

Readme

SOCKS/HTTP/HTTPS proxy implementation in node.js

A simple SOCKS/HTTP/HTTPS proxy implementation and demo proxy in node.js <http://nodejs.org>_.

It supports both socks5/socks4/socks4a/http/https proxy You can run it easily as:

node ./test/socksproxy5.js

node ./test/socksproxy4.js

node ./test/httpproxy.js

Under windows you can run run.vbs

This will create a proxy socks5 at 127.0.0.1 on port 8888.

This will create a proxy socks4 socks4a at 127.0.0.1 on port 9999.

This will create a proxy http https at 127.0.0.1 on port 8080.

All with user:password is user:pass

You can use this as a good starting point for writing a proxy or a tunnel!

Features

  • Supports SOCKS v4, v4a, and v5 proxy.
  • Supports HTTP/HTTPS proxy.
  • Supports the CONNECT and ASSOCIATE for SOCKS v5.
  • Supports user/pass authentication.
  • Supports Banned IPs.
  • Supports SSH relay (since v1.1.0).

Installation

npm install @sansamour/node-socks

Usage

// TypeScript
import { http, socks4, socks5 } from '@sansamour/node-socks';

// ES6 JavaScript
import { http, socks4, socks5 } from '@sansamour/node-socks';

// Legacy JavaScript
const socks5 = require('@sansamour/node-socks').socks5;

http.createServer(options);
socks4.createServer(options);
socks5.createServer(options);

Options

  • authorization - (< function >validateUserPassword) A function with two parameters (user, password).

  • fileBannedIPs - File location with content banned IPs semicolon separated.

  • onAccept - A callback function with four parameters (socket, info, accept, deny)

    • info < object > {srcAddr, srcPort, dstAddr, dstPort, numClients}
  • ssh - < object > {host, port, username, password}

  • timeout (< number > miliseconds) default: 60000

Quick Start Example

Create SOCKS v5 server: socks5://user:[email protected]:9999 with file banned IPs ip.txt (semicolon separated)

const { socks5 } = require('@sansamour/node-socks')

socks5.createServer({
	authorization: function(u,p){
		return u == 'user' && p == 'pass'
	},
	port: 9999,
	fileBannedIPs: './ip.txt'
});

With SOCKS v4/v4a proxy server support only Username Authentication (no Password). Create SOCKS v4/v4a server: socks4://user:[email protected]:8888 with file banned IPs ip.txt (semicolon separated)

const { socks4 } = require('@sansamour/node-socks')

socks4.createServer({
	authorization:function(u){
		return u == 'user'
	},
	port: 8888,
	fileBannedIPs: './ip.txt'
});

SSH relay example

const { socks5 } = require('@sansamour/node-socks')

socks5.createServer({	
	port: 9999,
	ssh:{
	    host: '103.92.28.100',
	    port: 22,
	    username: 'root',
	    password: 'xxxx'
	}
});

Example with onAccept: limit number of clients

    onAccept:function(socket, info, accept, deny){
		console.log(info)
		if(info.numClients > 100){
			return deny()
		}
		accept();
	}

Associate Example (UDP Relay) with SOCKS v5

Further Reading:

Detail about this package. http://tutorialspots.com/nodejs-create-socks4socks4asocks5httphttps-proxy-server-with-authentication-5653.html

Please read the SOCKS 5 specifications for more information on how to use Associate. http://www.ietf.org/rfc/rfc1928.txt

License

This work is licensed under the MIT license.