A shadowsocks implementation in golang with Multi-connection Acceleration.
The code is based on https://github.com/shadowsocks/go-shadowsocks2
Rabbit TCP is recommended.UPDATE 2019-10: Deprecated.
- SOCKS5 proxy with UDP Associate
- Support for Netfilter TCP redirect (IPv6 should work but not tested)
- UDP tunneling (e.g. relay DNS packets)
- TCP tunneling (e.g. benchmark with iperf3)
- Multi-connection Acceleration
Multi-connection Acceleration Protocol
In the original shadowsocks protocal, the data is transmitted in the following way:
client <---> ss-local <--[encrypted]--> ss-remote <---> target
The shadowsocks is used to access blocked servers.
In most common applications, the bottleneck of the bandwidth is the way outside their countries:
Is it the best way to communicate in one connection?
With a proper protocol, the
ss-remote can communicate in multi TCP connections,
which will be faster when transferring a large amount of data, especially for those slow VPS.
The following protocol by ihciah is one of them. The implementation in other language is welcome.
Establish the connection to shadowsocks server first.
Send address. Here I add 2 bits for "Magic":
After sending the address with
magic-main, the server will reply a 16-byte
Up till now we have 1 connection. Through the connection, data will be sent back in format
Of course, it's not acceleration with only 1 connection. With the
dataKeywe can construct an "address" in format
[Type(byte)][dataKey(byte)], the type must be marked as
Now create a new connection and send the 17-byte "address", then the data will be transmitted to the client.
Once the main connection(the first one) is disconnected, all the other connections will die. However, it's not a problem if the
Pre-built binaries for common platforms are available at https://github.com/ihciah/go-shadowsocks-magic/releases
Install from source
go get -u -v github.com/ihciah/go-shadowsocks-magic
Start a server listening on port 8488 using
RC4-MD5 cipher with password
shadowsocks-magic -s 'ss://RC4-MD5:your-password@:8488' -verbose
When deploy, you can close verbose.
Start a client connecting to the above server. The client listens on port 1080 for incoming SOCKS5 connections, and tunnels both UDP and TCP on port 8053 and port 8054 to 126.96.36.199:53 and 188.8.131.52:53 respectively.
shadowsocks-magic -c 'ss://RC4-MD5:your-password@[server_address]:8488' \ -verbose -socks :1080 -u -udptun :8053=184.108.40.206:53,:8054=220.127.116.11:53 \ -tcptun :8053=18.104.22.168:53,:8054=22.214.171.124:53
[server_address] with the server's public address.
Netfilter TCP redirect (Linux only)
The client offers
-redir6 (for IPv6) options to handle TCP connections
redirected by Netfilter on Linux. The feature works similar to
Start a client listening on port 1082 for redirected TCP connections and port 1083 for redirected TCP IPv6 connections.
shadowsocks-magic -c 'ss://RC4-MD5:your-password@[server_address]:8488' -redir :1082 -redir6 :1083
The client offers
-tcptun [local_addr]:[local_port]=[remote_addr]:[remote_port] option to tunnel TCP.
For example it can be used to proxy iperf3 for benchmarking.
Start iperf3 on the same machine with the server.
By default iperf3 listens on port 5201.
Start a client on the same machine with the server. The client listens on port 1090 for incoming connections and tunnels to localhost:5201 where iperf3 is listening.
shadowsocks-magic -c 'ss://RC4-MD5:your-password@[server_address]:8488' -tcptun :1090=localhost:5201
Start iperf3 client to connect to the tunneld port instead
iperf3 -c localhost -p 1090
The code base strives to
- be idiomatic Go and well organized;
- use fewer external dependences as reasonably possible;
- only include proven modern ciphers;