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.

241 lines
7.3 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
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/).
  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. ## Linux
  42. For Unix-like systems, especially Debian-based systems,
  43. e.g. Ubuntu, Debian or Linux Mint, you can build the binary like this:
  44. ```bash
  45. sudo apt-get install build-essential autoconf libtool libssl-dev
  46. ./configure && make
  47. sudo make install
  48. ```
  49. ### FreeBSD
  50. ```bash
  51. su
  52. cd /usr/ports/net/shadowsocks-libev
  53. make install
  54. ```
  55. Then add your configuration into /etc/rc.conf file:
  56. ```
  57. # RECOMMENDED
  58. shadowsocks_libev_enable="YES"
  59. shadowsocks_libev_flags="-c /PATH/TO/CONFIG.JSON"
  60. ```
  61. or you can omit the config.json file, specify arguments directly:
  62. ```
  63. shadowsocks_libev_enable="YES"
  64. shadowsocks_libev_password="YOUR PASSWORD"
  65. shadowsocks_libev_port="1080"
  66. shadowsocks_libev_localport="7070"
  67. ```
  68. Start the shadowsocks server:
  69. ```bash
  70. service shadowsocks_libev start
  71. ```
  72. ### OpenWRT
  73. ```bash
  74. # At OpenWRT build root
  75. pushd package
  76. git clone https://github.com/madeye/shadowsocks-libev.git
  77. popd
  78. # Enable shadowsocks-libev in network category
  79. make menuconfig
  80. # Optional
  81. make -j
  82. # Build the package
  83. make V=99 package/shadowsocks-libev/openwrt/compile
  84. ```
  85. ### Windows
  86. For Windows, use either MinGW (msys) or Cygwin to build.
  87. At the moment, only `ss-local` is supported to build against MinGW (msys).
  88. If you are using MinGW (msys), please download OpenSSL source tarball
  89. to the home directory of msys, and build it like this (may take a few minutes):
  90. ```bash
  91. tar zxf openssl-1.0.1e.tar.gz
  92. cd openssl-1.0.1e
  93. ./config --prefix="$HOME/prebuilt" --openssldir="$HOME/prebuilt/openssl"
  94. make && make install
  95. ```
  96. Then, build the binary using the commands below, and all `.exe` files
  97. will be built at `$HOME/ss/bin`:
  98. ```bash
  99. ./configure --prefix="$HOME/ss" --with-openssl="$HOME/prebuilt"
  100. make && make install
  101. ```
  102. Usage
  103. -----
  104. ```
  105. usage:
  106. ss-[local|redir|server]
  107. -s <server_host> host name or ip address of your remote server
  108. -p <server_port> port number of your remote server
  109. -l <local_port>> port number of your local server
  110. -k <password> password of your remote server
  111. [-m <encrypt_method>] encrypt method, supporting table, rc4,
  112. aes-128-cfb, aes-192-cfb, aes-256-cfb,
  113. bf-cfb, camellia-128-cfb, camellia-192-cfb,
  114. camellia-256-cfb, cast5-cfb, des-cfb,
  115. idea-cfb, rc2-cfb and seed-cfb
  116. [-f <pid_file>] valid path to the pid file
  117. [-t <timeout>] socket timeout in seconds
  118. [-c <config_file>] json format config file
  119. [-i <interface>] specific network interface to bind,
  120. only avaliable in local and server modes
  121. [-b <local_address>] specific local address to bind,
  122. only avaliable in local and redir modes
  123. [-u] udprelay mode to supprot udp traffic
  124. only avaliable in local and server modes
  125. [-v] verbose mode, debug output in console
  126. notes:
  127. ss-redir provides a transparent proxy function and only works on the
  128. Linux platform with iptables.
  129. ```
  130. ## Advanced usage
  131. The latest shadowsocks-libev has provided a *redir* mode. You can configure your linux based box or router to proxy all tcp traffic transparently.
  132. # Create new chain
  133. root@Wrt:~# iptables -t nat -N SHADOWSOCKS
  134. # Ignore your shadowsocks server's addresses
  135. # It's very IMPORTANT, just be careful.
  136. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 123.123.123.123 -j RETURN
  137. # Ignore LANs and any other addresses you'd like to bypass the proxy
  138. # See Wikipedia and RFC5735 for full list of reserved networks.
  139. # See ashi009/bestroutetb for a highly optimized CHN route list.
  140. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN
  141. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
  142. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
  143. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
  144. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
  145. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
  146. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
  147. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN
  148. # Anything else should be redirected to shadowsocks's local port
  149. root@Wrt:~# iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 12345
  150. # Apply the rules
  151. root@Wrt:~# iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
  152. # Start the shadowsocks-redir
  153. root@Wrt:~# ss-redir -c /etc/config/shadowsocks.json -f /var/run/shadowsocks.pid
  154. ## Security Tips
  155. Although shadowsocks-libev can handle thousands of concurrent connections nicely, we still recommend to
  156. set up your server's firewall rules to limit connections from each user.
  157. # Up to 32 connections are enough for normal usages
  158. iptables -A INPUT -p tcp --syn --dport ${SHADOWSOCKS_PORT} -m connlimit --connlimit-above 32 -j REJECT --reject-with tcp-reset
  159. ## License
  160. Copyright (C) 2013 Max Lv <max.c.lv@gmail.com>
  161. This program is free software: you can redistribute it and/or modify
  162. it under the terms of the GNU General Public License as published by
  163. the Free Software Foundation, either version 3 of the License, or
  164. (at your option) any later version.
  165. This program is distributed in the hope that it will be useful,
  166. but WITHOUT ANY WARRANTY; without even the implied warranty of
  167. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  168. GNU General Public License for more details.
  169. You should have received a copy of the GNU General Public License
  170. along with this program. If not, see <http://www.gnu.org/licenses/>.