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.

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