You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
8.7 KiB

12 years ago
12 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
11 years ago
12 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. shadowsocks-libev
  2. =================
  3. Intro
  4. -----
  5. [Shadowsocks-libev](http://shadowsocks.org) is a lightweight secured scoks5
  6. proxy for embedded devices and low end boxes.
  7. It is a port of [shadowsocks](https://github.com/clowwindy/shadowsocks)
  8. created by [@clowwindy](https://github.com/clowwindy) maintained by
  9. [@madeye](https://github.com/madeye) and [@linusyang](https://github.com/linusyang).
  10. Current version: 1.4.2 | [![Build Status](https://travis-ci.org/madeye/shadowsocks-libev.png?branch=master)](https://travis-ci.org/madeye/shadowsocks-libev)
  11. Changelog
  12. ---------
  13. 1.4.2 -- Sun, 05 Jan 2014 10:05:29 +0900
  14. * Fix the UDP relay issues.
  15. * Add syslog support.
  16. 1.4.1 -- Tue, 12 Nov 2013 03:57:21 +0000
  17. * Add multi-port support.
  18. * Add PolarSSL support by @linusyang.
  19. 1.4.0 -- Sun, 08 Sep 2013 02:20:40 +0000
  20. * Add standard socks5 udp support.
  21. 1.3.3 -- Fri, 21 Jun 2013 09:59:20 +0800
  22. * Provide more info in verbose mode.
  23. 1.3.2 -- Sun, 09 Jun 2013 09:52:31 +0000
  24. * Fix some ciphers by @linusyang.
  25. 1.3.1 -- Tue, 04 Jun 2013 00:56:17 +0000
  26. * Support more cihpers: camellia, idea, rc2 and seed.
  27. 1.3 -- Thu, 16 May 2013 10:51:15 +0800
  28. * Able to bind connections to specific interface
  29. * Support more ciphers: aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, cast5-cfb, des-cfb
  30. 1.2 -- Tue, 07 May 2013 14:10:33 +0800
  31. * Close timeouted TCP connections
  32. * Fix a high load issue
  33. 1.1 -- Wed, 10 Apr 2013 12:11:36 +0800
  34. * Fix a IPV6 resolve issue
  35. 1.0 -- Sat, 06 Apr 2013 16:59:15 +0800
  36. * Initial release
  37. Features
  38. --------
  39. Shadowsocks-libev is writen in pure C and only depends on
  40. [libev](http://software.schmorp.de/pkg/libev.html) and
  41. [openssl](http://www.openssl.org/) or [polarssl](https://polarssl.org/).
  42. In normal usage, the memory consumption is about 600KB and the CPU utilization is
  43. no more than 5% on a low-end router (Buffalo WHR-G300N V2 with a 400MHz MIPS CPU,
  44. 32MB memory and 4MB flash).
  45. Installation
  46. ------------
  47. #### Notes about PolarSSL
  48. * Default crypto library is OpenSSL. To build against PolarSSL,
  49. specify `--with-crypto-library=polarssl` and `--with-polarssl=/path/to/polarssl`
  50. when running `./configure`.
  51. * PolarSSL __1.2.5 or newer__ is required. Currently, PolarSSL does __NOT__ support
  52. CAST5-CFB, DES-CFB, IDEA-CFB, RC2-CFB and SEED-CFB.
  53. * RC4 is only support by PolarSSL __1.3.0 or above__.
  54. ### Debian & Ubuntu
  55. Add either of the following lines to your /etc/apt/sources.list
  56. ```
  57. # Debian Wheezy, Ubuntu 12.04 or any distribution with libssl > 1.0.1
  58. deb http://shadowsocks.org/debian wheezy main
  59. # Debian Squeeze, Ubuntu 11.04, or any distribution with libssl > 0.9.8, but < 1.0.0
  60. deb http://shadowsocks.org/debian squeeze main
  61. ```
  62. Then,
  63. ``` bash
  64. sudo apt-get update
  65. sudo apt-get install shadowsocks
  66. # Edit the configuration
  67. sudo vim /etc/shadowsocks/config.json
  68. # Start the service
  69. sudo /etc/init.d/shadowsocks start
  70. ```
  71. ### Linux
  72. For Unix-like systems, especially Debian-based systems,
  73. e.g. Ubuntu, Debian or Linux Mint, you can build the binary like this:
  74. ```bash
  75. sudo apt-get install build-essential autoconf libtool libssl-dev
  76. ./configure && make
  77. sudo make install
  78. ```
  79. ### FreeBSD
  80. ```bash
  81. su
  82. cd /usr/ports/net/shadowsocks-libev
  83. make install
  84. ```
  85. Edit your config.json file. By default, it's located in /usr/local/etc/shadowsocks-libev
  86. To enable shadowsocks-libev, add the following rc variable to your /etc/rc.conf file.
  87. ```
  88. shadowsocks_libev_enable="YES"
  89. ```
  90. Start the shadowsocks server:
  91. ```bash
  92. service shadowsocks_libev start
  93. ```
  94. ### OpenWRT
  95. ```bash
  96. # At OpenWRT build root
  97. pushd package
  98. git clone https://github.com/madeye/shadowsocks-libev.git
  99. popd
  100. # Enable shadowsocks-libev in network category
  101. make menuconfig
  102. # Optional
  103. make -j
  104. # Build the package
  105. make V=99 package/shadowsocks-libev/openwrt/compile
  106. ```
  107. ### Windows
  108. For Windows, use either MinGW (msys) or Cygwin to build.
  109. At the moment, only `ss-local` is supported to build against MinGW (msys).
  110. If you are using MinGW (msys), please download OpenSSL or PolarSSL source tarball
  111. to the home directory of msys, and build it like this (may take a few minutes):
  112. * OpenSSL
  113. ```bash
  114. tar zxf openssl-1.0.1e.tar.gz
  115. cd openssl-1.0.1e
  116. ./config --prefix="$HOME/prebuilt" --openssldir="$HOME/prebuilt/openssl"
  117. make && make install
  118. ```
  119. * PolarSSL
  120. ```bash
  121. tar zxf polarssl-1.3.2-gpl.tgz
  122. cd polarssl-1.3.2
  123. make lib WINDOWS=1
  124. make install DESTDIR="$HOME/prebuilt"
  125. ```
  126. Then, build the binary using the commands below, and all `.exe` files
  127. will be built at `$HOME/ss/bin`:
  128. * OpenSSL
  129. ```bash
  130. ./configure --prefix="$HOME/ss" --with-openssl="$HOME/prebuilt"
  131. make && make install
  132. ```
  133. * PolarSSL
  134. ```bash
  135. ./configure --prefix="$HOME/ss" --with-crypto-library=polarssl --with-polarssl=$HOME/prebuilt
  136. make && make install
  137. ```
  138. Usage
  139. -----
  140. ```
  141. usage:
  142. ss-[local|redir|server]
  143. -s <server_host> host name or ip address of your remote server
  144. -p <server_port> port number of your remote server
  145. -l <local_port> port number of your local server
  146. -k <password> password of your remote server
  147. [-m <encrypt_method>] encrypt method, supporting table, rc4,
  148. aes-128-cfb, aes-192-cfb, aes-256-cfb,
  149. bf-cfb, camellia-128-cfb, camellia-192-cfb,
  150. camellia-256-cfb, cast5-cfb, des-cfb,
  151. idea-cfb, rc2-cfb and seed-cfb
  152. [-f <pid_file>] valid path to the pid file
  153. [-t <timeout>] socket timeout in seconds
  154. [-c <config_file>] json format config file
  155. [-i <interface>] specific network interface to bind,
  156. only available in local and server modes
  157. [-b <local_address>] specific local address to bind,
  158. only available in local and redir modes
  159. [-u] udprelay mode to supprot udp traffic
  160. only available in local and server modes
  161. [-v] verbose mode, debug output in console
  162. notes:
  163. ss-redir provides a transparent proxy function and only works on the
  164. Linux platform with iptables.
  165. ```
  166. ## Advanced usage
  167. The latest shadowsocks-libev has provided a *redir* mode. You can configure your linux based box or router to proxy all tcp traffic transparently.
  168. # Create new chain
  169. root@Wrt:~# iptables -t nat -N SHADOWSOCKS
  170. # Ignore your shadowsocks server's addresses
  171. # It's very IMPORTANT, just be careful.
  172. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 123.123.123.123 -j RETURN
  173. # Ignore LANs and any other addresses you'd like to bypass the proxy
  174. # See Wikipedia and RFC5735 for full list of reserved networks.
  175. # See ashi009/bestroutetb for a highly optimized CHN route list.
  176. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN
  177. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
  178. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
  179. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
  180. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
  181. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
  182. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
  183. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN
  184. # Anything else should be redirected to shadowsocks's local port
  185. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 12345
  186. # Apply the rules
  187. root@Wrt:~# iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
  188. # Start the shadowsocks-redir
  189. root@Wrt:~# ss-redir -c /etc/config/shadowsocks.json -f /var/run/shadowsocks.pid
  190. ## Security Tips
  191. Although shadowsocks-libev can handle thousands of concurrent connections nicely, we still recommend to
  192. set up your server's firewall rules to limit connections from each user.
  193. # Up to 32 connections are enough for normal usages
  194. iptables -A INPUT -p tcp --syn --dport ${SHADOWSOCKS_PORT} -m connlimit --connlimit-above 32 -j REJECT --reject-with tcp-reset
  195. ## License
  196. Copyright (C) 2013 Max Lv <max.c.lv@gmail.com>
  197. This program is free software: you can redistribute it and/or modify
  198. it under the terms of the GNU General Public License as published by
  199. the Free Software Foundation, either version 3 of the License, or
  200. (at your option) any later version.
  201. This program is distributed in the hope that it will be useful,
  202. but WITHOUT ANY WARRANTY; without even the implied warranty of
  203. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  204. GNU General Public License for more details.
  205. You should have received a copy of the GNU General Public License
  206. along with this program. If not, see <http://www.gnu.org/licenses/>.