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.

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