├── Makefile ├── README.md └── files ├── shadowsocksr ├── shadowsocksr-server ├── shadowsocksr-server.json └── shadowsocksr.json /Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=shadowsocksR-libev 4 | PKG_VERSION:=2.5.6 5 | PKG_RELEASE:=2 6 | 7 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.gz 8 | PKG_SOURCE_URL:=https://github.com/ssrbackup/shadowsocksr-libev.git 9 | PKG_SOURCE_PROTO:=git 10 | PKG_SOURCE_VERSION:=f713aa981169d35ff9483b295d1209c35117d70c 11 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 12 | PKG_MAINTAINER:=breakwa11 13 | 14 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) 15 | 16 | PKG_INSTALL:=1 17 | PKG_FIXUP:=autoreconf 18 | PKG_USE_MIPS16:=0 19 | PKG_BUILD_PARALLEL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | 23 | define Package/shadowsocksr-libev/Default 24 | SECTION:=net 25 | CATEGORY:=Network 26 | TITLE:=Lightweight Secured Socks5 Proxy 27 | URL:=https://github.com/shadowsocksr/shadowsocksr-libev 28 | endef 29 | 30 | define Package/shadowsocksr-libev 31 | $(call Package/shadowsocksr-libev/Default) 32 | TITLE+= (OpenSSL) 33 | VARIANT:=openssl 34 | DEPENDS:=+libopenssl +libpcre +libpthread +zlib 35 | endef 36 | 37 | 38 | define Package/shadowsocksr-libev-mbedtls 39 | $(call Package/shadowsocksr-libev/Default) 40 | TITLE+= (mbedTLS) 41 | VARIANT:=mbedtls 42 | DEPENDS:=+libpthread +libpcre +libmbedtls 43 | endef 44 | 45 | 46 | define Package/shadowsocksr-libev/description 47 | ShadowsocksR-libev is a lightweight secured socks5 proxy for embedded devices and low end boxes. 48 | endef 49 | 50 | 51 | Package/shadowsocksr-libev-mbedtls/description=$(Package/shadowsocksr-libev/description) 52 | 53 | define Package/shadowsocksr-libev/conffiles 54 | /etc/shadowsocksr.json 55 | endef 56 | 57 | Package/shadowsocksr-libev-polarssl/conffiles = $(Package/shadowsocksr-libev/conffiles) 58 | Package/shadowsocksr-libev-mbedtls/conffiles = $(Package/shadowsocksr-libev/conffiles) 59 | 60 | define Package/shadowsocksr-libev-server/conffiles 61 | /etc/shadowsocksr-server.json 62 | endef 63 | 64 | Package/shadowsocksr-libev-server-mbedtls/conffiles = $(Package/shadowsocksr-libev-server/conffiles) 65 | 66 | 67 | CONFIGURE_ARGS += --disable-ssp --disable-documentation --disable-assert 68 | 69 | ifeq ($(BUILD_VARIANT),openssl) 70 | CONFIGURE_ARGS += --with-crypto-library=openssl 71 | endif 72 | 73 | ifeq ($(BUILD_VARIANT),mbedtls) 74 | CONFIGURE_ARGS += --with-crypto-library=mbedtls 75 | endif 76 | 77 | define Package/shadowsocksr-libev/install 78 | $(INSTALL_DIR) $(1)/etc/init.d 79 | #$(INSTALL_BIN) ./files/shadowsocksr $(1)/etc/init.d/shadowsocksr 80 | $(INSTALL_CONF) ./files/shadowsocksr.json $(1)/etc/shadowsocksr.json 81 | $(INSTALL_DIR) $(1)/usr/bin 82 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/ss-local $(1)/usr/bin/ssrr-local 83 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/ss-redir $(1)/usr/bin/ssrr-redir 84 | endef 85 | 86 | Package/shadowsocksr-libev-polarssl/install=$(Package/shadowsocksr-libev/install) 87 | Package/shadowsocksr-libev-mbedtls/install=$(Package/shadowsocksr-libev/install) 88 | 89 | Package/shadowsocksr-libev-server-mbedtls/install=$(Package/shadowsocksr-libev-server/install) 90 | 91 | $(eval $(call BuildPackage,shadowsocksr-libev)) 92 | $(eval $(call BuildPackage,shadowsocksr-libev-mbedtls)) 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Shadowsocksr-libev for OpenWrt/LEDE 2 | === 3 | 版本 2.5.6 2017.6.13破娃酱最后一commit 4 | 5 | 相比2016-stable分支,有如下不同 6 | 7 | 1、支持auth_chain_a; 8 | 9 | 2、ssr-tunnel合并进ssr-local 10 | 11 | 3、去掉ssr-server 12 | 13 | 14 | 为编译[此固件][O]所需依赖包而写的Makefile,在CC 15.05,CC 15.05.1,LEDE 17.01.1 17.01.2编译成功 15 | 16 | 简介 17 | --- 18 | 19 | 本项目是 [shadowsocksr-libev][1] 在 OpenWrt 上的移植 ,写法参考https://github.com/shadowsocks/openwrt-shadowsocks/ 20 | 21 | 可与[luci-app-shadowsocksR][P]搭配使用 22 | 23 | 24 | 特性 25 | --- 26 | 27 | 软件包只包含 [shadowsocksr-libev][1] 的可执行文件 28 | 可编译两种版本 29 | 30 | - shadowsocksr-libev 31 | 32 | ``` 33 | 客户端/ 34 | └── usr/ 35 | └── bin/ 36 | ├── ssrr-local // 提供 SOCKS 代理和旧版ssr-tunnel的端口转发功能 37 | └── ssrr-redir // 提供透明代理, 从 v2.2.0 开始支持 UDP 38 | ``` 39 | 40 | 41 | 42 | 获取最新代码 43 | --- 44 | 可以修改Makefile中PKG_SOURCE_VERSION为你需要编译的commit id 45 | 46 | 编译 47 | --- 48 | 49 | - 从 OpenWrt 的 [SDK][S] 编译 50 | 51 | ```bash 52 | # 以 ar71xx 平台为例 53 | tar xjf OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2 54 | cd OpenWrt-SDK-ar71xx-* 55 | # 安装 feeds 56 | # 方案一(推荐):使用自定义feeds 57 | git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds 58 | # 方案二:使用官方feeds 59 | ./scripts/feeds update base packages 60 | ./scripts/feeds install zlib libopenssl libpolarssl libmbedtls libpcre 61 | rm -rf package/feeds/base/mbedtls/patches 62 | # 获取 shadowsocksr-libev Makefile 63 | git clone https://github.com/AlexZhuo/openwrt-shadowsocksr.git package/shadowsocksr-libev 64 | # 选择要编译的包 Network -> shadowsocksr-libev 65 | make menuconfig 66 | # 开始编译 67 | make package/shadowsocksr-libev/compile V=99 68 | ``` 69 | 70 | 编译错误汇总 71 | --- 72 | 1、报错`C compiler cannot create executables` 73 | 74 | 错误原因:当前Linux系统没有完整的编译环境 75 | 76 | 解决方法:sudo apt-get install ccache build-essential 77 | 78 | 79 | 2、报错`configure: error: PolarSSL libraries not found.` 80 | 81 | 错误原因:SDK没有找到PolarSSl的feed 82 | 83 | 解决方法:git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds 84 | 85 | 86 | 3、报错`configure: error: "zlib header files not found."` 87 | 88 | 错误原因:SDK没有找到libopenssl和zlib的feed,该问题会出现在LEDE rc1的SDK中,使用17.01.0 SDK不会有这个问题 89 | 90 | 解决方法:git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds 91 | 92 | 93 | 4、报错 94 | ``` 95 | checking for pcre-config... pcre-config 96 | checking for pcre headers in ... not found 97 | checking for library containing pcre_exec... no 98 | configure: error: Cannot find pcre library. Configure --with-pcre=DIR 99 | ``` 100 | 报错原因:SDK没有找到pcre的feed 101 | 102 | 解决方法:git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds或者 103 | 104 | ./scripts/feeds update base packages 105 | 106 | ./scripts/feeds install libpcre 107 | 108 | 109 | 5、执行`./scripts/feeds install zlib libopenssl libpolarssl libmbedtls libpcre`时输出不为如下标准输出 110 | ``` 111 | Installing package 'zlib' from base 112 | Installing package 'openssl' from base 113 | Installing package 'libpolarssl' from base 114 | Installing package 'mbedtls' from base 115 | Installing package 'pcre' from packages 116 | ``` 117 | 而是报找不到feed的错误,如下 118 | ``` 119 | WARNING: No feed for package 'zlib' found, maybe it's already part of the standard packages? 120 | WARNING: No feed for package 'libopenssl' found, maybe it's already part of the standard packages? 121 | WARNING: No feed for package 'libpolarssl' found, maybe it's already part of the standard packages? 122 | WARNING: No feed for package 'libmbedtls' found, maybe it's already part of the standard packages? 123 | Installing package 'pcre' from packages 124 | ``` 125 | 126 | 报错原因:一般出现在LEDE rc1,rc2的SDK上,把17.0.2 LEDE SDK中的feeds.conf.default文件内容复制到SDK中去就可以了。 127 | 128 | 解决方法:更换SDK,或者修改SDK根目录下的feeds.conf.default文件 129 | ``` 130 | src-git base https://git.lede-project.org/source.git;v17.01.2 131 | src-git packages https://git.lede-project.org/feed/packages.git^dc558eaa296686603c1730c1aab01f3ea69d7831 132 | src-git luci https://git.lede-project.org/project/luci.git^7f6fc1681f7becc514a58082e871f3855d3a123f 133 | src-git routing https://git.lede-project.org/feed/routing.git^dbbad8472288498c17825303d834da3ee5030806 134 | src-git telephony https://git.lede-project.org/feed/telephony.git^1f0fb2538ba6fc306198fe2a9a4b976d63adb304 135 | ``` 136 | 或 137 | 138 | git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds 139 | 140 | 141 | 6、报错 142 | ``` 143 | checking for cipher_init_ctx in -lpolarssl... no 144 | configure: error: PolarSSL libraries not found. 145 | ``` 146 | 报错原因:官方源缺少PolarSSl依赖 147 | 148 | 解决方法:复制https://github.com/AlexZhuo/openwrt-feeds/tree/master/base/ 中polarssl文件夹到SDK根目录/package/feeds/base 149 | 150 | 7、报错 151 | ``` 152 | checking whether mbedtls supports the Camellia block cipher or not... configure: error: MBEDTLS_CAMELLIA_C required 153 | ``` 154 | 报错原因:官方源mbedtls版本太高,应该使用2.4.0 155 | 156 | 解决方法:复制https://github.com/AlexZhuo/openwrt-feeds/tree/master/base 中mbedtls文件夹替换SDK根目录/package/feeds/base/mbedtls 157 | 158 | 159 | 160 | 配置 161 | --- 162 | 163 | 软件包本身并不包含配置文件, 配置文件内容为 JSON 格式, 支持的键: 164 | 165 | 键名 | 数据类型 | 说明 166 | ---------------|----------|----------------------------------------------- 167 | server | 字符串 | 服务器地址, 可以是 IP 或者域名 168 | server_port | 整数值 | 服务器端口号 169 | local_address | 字符串 | 本地绑定的 IP 地址, 默认 `127.0.0.1` 170 | local_port | 整数值 | 本地绑定的端口号 171 | password | 字符串 | 服务端设置的密码 172 | method | 字符串 | 加密方式, [详情参考][E] 173 | timeout | 整数值 | 超时时间(秒), 默认 60 174 | fast_open | 布尔值 | 是否启用 [TCP Fast Open][F], 只适用于 `ss-local`, `ss-server` 175 | auth | 布尔值 | 是否启用[一次验证][A] 176 | nofile | 整数值 | 设置 Linux ulimit 177 | protocol | 字符串 | 混淆协议 [详情][N] 178 | protocol_param | 字符串 | 协议参数 [详情][N] 179 | obfs | 字符串 | 混淆方式 [详情][N] 180 | obfs_param | 字符串 | 混淆参数 [详情][N] 181 | 182 | [1]: https://github.com/shadowsocksr/shadowsocksr-libev 183 | [2]: https://bintray.com/aa65535/opkg/shadowsocks-libev/_latestVersion "预编译 IPK 下载" 184 | [B]: https://api.bintray.com/packages/aa65535/opkg/shadowsocks-libev/images/download.svg 185 | [3]: https://github.com/shadowsocks/luci-app-shadowsocks 186 | [A]: https://shadowsocks.org/en/spec/one-time-auth.html 187 | [E]: https://github.com/shadowsocks/luci-app-shadowsocks/wiki/Encrypt-method 188 | [F]: https://github.com/shadowsocks/shadowsocks/wiki/TCP-Fast-Open 189 | [S]: https://wiki.openwrt.org/doc/howto/obtain.firmware.sdk 190 | [M]: https://www.multipath-tcp.org/ 191 | [N]: https://github.com/breakwa11/shadowsocks-rss/blob/master/ssr.md 192 | [O]: http://www.right.com.cn/forum/thread-198649-1-1.html 193 | [P]: https://github.com/AlexZhuo/luci-app-shadowsocksR 194 | -------------------------------------------------------------------------------- /files/shadowsocksr: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=95 4 | 5 | SERVICE_USE_PID=1 6 | SERVICE_WRITE_PID=1 7 | SERVICE_DAEMONIZE=1 8 | 9 | CONFIG=/etc/shadowsocksr.json 10 | 11 | start() { 12 | service_start /usr/bin/ssr-local -c $CONFIG 13 | #service_start /usr/bin/ssr-redir -c $CONFIG 14 | #service_start /usr/bin/ssr-tunnel -c $CONFIG -l 5353 -L 8.8.8.8:53 -U 15 | } 16 | 17 | stop() { 18 | service_stop /usr/bin/ssr-local 19 | #service_stop /usr/bin/ssr-redir 20 | #service_stop /usr/bin/ssr-tunnel 21 | } 22 | -------------------------------------------------------------------------------- /files/shadowsocksr-server: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=95 4 | 5 | SERVICE_USE_PID=1 6 | SERVICE_WRITE_PID=1 7 | SERVICE_DAEMONIZE=1 8 | 9 | CONFIG=/etc/shadowsocksr-server.json 10 | 11 | start() { 12 | service_start /usr/bin/ssr-server -c $CONFIG -u 13 | } 14 | 15 | stop() { 16 | service_stop /usr/bin/ssr-server 17 | } 18 | -------------------------------------------------------------------------------- /files/shadowsocksr-server.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": "0.0.0.0", 3 | "server_ipv6": "::", 4 | "server_port": 443, 5 | "password": "password", 6 | "method": "rc4-md5", 7 | "timeout": 120, 8 | "protocol": "origin", 9 | "protocol_param": "", 10 | "obfs": "plain", 11 | "obfs_param": "", 12 | "redirect": "", 13 | "dns_ipv6": false, 14 | "fast_open": false 15 | } 16 | -------------------------------------------------------------------------------- /files/shadowsocksr.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": "0.0.0.0", 3 | "server_ipv6": "::", 4 | "server_port": 443, 5 | "password": "password", 6 | "method": "rc4-md5", 7 | "timeout": 120, 8 | "protocol": "origin", 9 | "protocol_param": "", 10 | "obfs": "plain", 11 | "obfs_param": "", 12 | "redirect": "", 13 | "dns_ipv6": false, 14 | "fast_open": false 15 | } 16 | --------------------------------------------------------------------------------