Git Product home page Git Product logo

nysocks's Introduction

nysocks

npm-version travis-ci

Nysocks binds kcp and libuv to provide a tcp tunnel in nodejs.

Nysocks is in an early stage. Please submit PRs or issues to help us improve it if you like it!

Proxy tests from a Linode instance(Tokyo 2, JP) where 10% packet loss always happens when trasmission data from to China mainland:

tcp proxy:

nysocks fast mode:

nysocks fast2 mode:

How it works

work

protocol(unstable):

+-----+-----+---------+-------+---------+--------+------------+
| ver | cmd |  nonce  |  kcp  | mux.cmd | mux.id | mux.length |
+-----+-----+---------+-------+---------+--------+------------+
|  1  |  1  |    8    |  24   |    1    |    2   |     4      |
+-----+-----+---------+-------+---------+--------+------------+

About the Tunnel Implementation

The tunnel connections in nysocks is implemented as a node-addon(C/CPP) mainly because:

  1. Node don't support setting send/recv buffer size of udp connections before v8.7.0.
  2. In large data transmissions, udp message callback is too frequently and manipulating buffers in js(or any other script languages) is relatively expensive which would make the total performace unacceptable. You can check my pure js implementation here.

Still, I'm not a professional C/CPP language user or network programmer. Please submit PRs or issues to help us improve it!

Installation

node >= 6.x

Make sure you have node-gyp installed successfully as nysocks will build C/CPP code, then:

npm i nysocks -g

Usage

1. Create server service

In your server, start nysocks with server command:

nysocks server -p 20000 -k YOUR_PASSWORD -m fast

2. Create client service

In your client, start nysocks with client command to create a tunnel client that will connect to your server and provide proxy service:

nysocks client -a YOUR_SERVER_HOST -p 20000 -k YOUR_PASSWORD -m fast

Nysocks will start a SOCKS5 service to tunnel your tcp connections. Now you can utilize the SOCKS5 service (default port 1080). A PAC file server will also be served(default port 8090) for convenience.

3. Use config.json

You can create a config.json file like this that containing your configs to avoid verbose cli options:

nysocks client -c config.json

4. Use daemons

Add -d options if you want to run under daemons(pm2):

nysocks client -d restart -c config.json

5. Check other options

Modify your options in the CLI. See other options here:

nysocks -h

Configs

{
  "serverAddr": "YOUR_SERVER_HOST",
  "serverPort": 20000,
  "socketAmount": 20,
  "password": "YOUR_PASSWORD",
  "kcp": {
    "sndwnd": 4096,
    "rcvwnd": 4096,
    "nodelay": 0,
    "interval": 30,
    "resend": 2,
    "nc": 1
  },
  "pac": {
    "pacServerPort": 8090
  },
  "SOCKS": {
    "port": 1080
  }
}

How to utilize the SOCKS5 service

Most OSes support SOCKS5 proxy by default:

osx-set-proxy

Use chrome extensions like SwitchyOmega to help browse web pages by proxy.

Encryption

aes_256_cbc

Known Issues

  • Do not support ipv6 currently.
  • Changing the ip of the client will disconnect all the connections temporary.

References

LICENSE

BSD

nysocks's People

Contributors

oyyd avatar nizihabi avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.