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

socks-proxy-v5

v0.8.0

Published

Implementation of socks 5 version on node js

Downloads

12

Readme

Socks5 protocol

Implementation of socks 5 version on node js

Does't support ipv6 address and udp/bind methods

Requirements

  • Node.js v16.0+

Installation

  npm install socks-proxy-v5

TODO

  • [ ] IPV6 support
  • [ ] UDP ASSOCIATE
  • [ ] BIND

Server

Create simple server

const { createServer } = require("socks-proxy-v5");

const server = createServer();

server.listen(1080); // any port

Create server with authentication

const { createServer } = require("socks-proxy-v5");

const server = createServer({
  authenticate(login, password) {
    // verify name/password
    if (login !== "foo" || password !== "bar") {
      console.log("authentication failed", login);
      return false; 
      // authentication failed
    }
    console.log(`user ${login} connect`);
    // return successful authentication
    return true;
  }
});

server.listen(1080);

Create server with filter

const { createServer }  = require("socks-proxy-v5");

const setAddr = new Set(["tools.ietf.org", "github.com", "2ip.ru"]);

const server = createServer({
  filter(addr) {
    const result = !setAddr.has(addr); 
    if(!result) console.log(`host ${addr} unreachable`);
    return result;
  }
});

createServer(options)

options - is an object that describes how to use a proxy server. (optional)

  • timeout - type number. Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Default set 2 minute. If timeout is 0, then the existing idle timeout is disabled

    const { createServer }  = require("socks-proxy-v5");
    const server = createServer({
      timeout: 10000 // 10 second
    });

    After timeout the socket will be destroyed

  • authenticate(login, password) - type function. Have two argument type string.Returns true if the user is authenticated, else false
    You can make queries to the database, create arrays of data, log users, you are limited only by your imagination

  • filter(address) - type function. Have one argument, type string. Returns true if the user has been filtered, else false
    You can use regular expressions, iterating over an array, or using new data types as an example (new Set), queries to the data base

Server Events (optional)

  • connect
    Emitted when a socket connection is successfully established

    server.on("connect", info =>
      console.log(`connected to remote server at ${info.addr}:${info.port}`)
    );
  • connection
    Emitted when a new connection is made. socket is an instance of net.Socket

    server.on("connection", socket => {
      console.log("new socks connection", socket.remoteAddress, socket.remotePort);
    });
  • error
    Emitted when an error occurs.

    server.on("error", error => {
      console.error(error);
    });
  • data
    Emitted when data is received. The argument data will be a Buffer or String

    server.on("data", data => console.log(data));
  • listening
    Emitted when the server has been bound after calling server.listen()

    server.listen(1080);
    
    server.on("listening", () => {
      console.log(
        `server listening ${server.address().address}:${server.address().port}`
      );
    });

server.listen(options)

work like server.listen()

See more

RFC1928, RFC1929
examples

License

MIT