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:
protocol(unstable):
+-----+-----+---------+-------+---------+--------+------------+
| ver | cmd | nonce | kcp | mux.cmd | mux.id | mux.length |
+-----+-----+---------+-------+---------+--------+------------+
| 1 | 1 | 8 | 24 | 1 | 2 | 4 |
+-----+-----+---------+-------+---------+--------+------------+
The tunnel connections in nysocks is implemented as a node-addon(C/CPP) mainly because:
- Node don't support setting send/recv buffer size of udp connections before v8.7.0.
- 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!
node >= 6.x
Make sure you have node-gyp installed successfully as nysocks will build C/CPP code, then:
npm i nysocks -g
In your server, start nysocks with server
command:
nysocks server -p 20000 -k YOUR_PASSWORD -m fast
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.
You can create a config.json
file like this that containing your configs to avoid verbose cli options:
nysocks client -c config.json
Add -d
options if you want to run under daemons(pm2):
nysocks client -d restart -c config.json
Modify your options in the CLI. See other options here:
nysocks -h
{
"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
}
}
Most OSes support SOCKS5 proxy by default:
Use chrome extensions like SwitchyOmega to help browse web pages by proxy.
aes_256_cbc
- Do not support ipv6 currently.
- Changing the ip of the client will disconnect all the connections temporary.
- kcptun - A Secure Tunnel Based On KCP with N:M Multiplexing
- kcp - A Fast and Reliable ARQ Protocol
- C++ and Node.js Integration
BSD