├── .gitignore ├── Makefile ├── README.md └── files └── redsocks2.template /.gitignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2014 OpenWrt-dist 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | 11 | PKG_NAME:=redsocks2 12 | PKG_VERSION:=0.67 13 | PKG_RELEASE:=1 14 | 15 | PKG_SOURCE_PROTO:=git 16 | PKG_SOURCE_URL:=https://github.com/semigodking/redsocks.git 17 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 18 | PKG_SOURCE_VERSION:=3052eeab75ff1ebd20c22334fbbecd808525bca7 19 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz 20 | PKG_MAINTAINER:=semigodking 21 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) 22 | 23 | include $(INCLUDE_DIR)/package.mk 24 | 25 | define Package/redsocks2 26 | SECTION:=net 27 | CATEGORY:=Network 28 | TITLE:=Redirect any TCP connection to a SOCKS or HTTPS proxy server 29 | URL:=https://github.com/semigodking/redsocks 30 | DEPENDS:=+libevent2 +libopenssl 31 | endef 32 | 33 | define Package/redsocks2/description 34 | This is a modified version of original redsocks. \ 35 | The name is changed to be REDSOCKS2 since this release to distinguish with original redsocks. \ 36 | This variant is useful for anti-GFW (Great Fire Wall). 37 | endef 38 | 39 | define Package/redsocks2/conffiles 40 | /etc/config/redsocks2 41 | endef 42 | 43 | #define Build/Compile 44 | # $(call Build/Compile/Default,ENABLE_HTTPS_PROXY=true) 45 | #endef 46 | 47 | define Package/redsocks2/install 48 | $(INSTALL_DIR) $(1)/usr/sbin 49 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/redsocks2 $(1)/usr/sbin 50 | $(INSTALL_DIR) $(1)/etc/redsocks2 51 | $(INSTALL_DATA) ./files/redsocks2.template $(1)/etc/redsocks2/config.template 52 | endef 53 | 54 | $(eval $(call BuildPackage,redsocks2)) 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RedSocks2 for OpenWrt 2 | === 3 | 版本 0.66 4 | 5 | 为编译[此固件][N]所需依赖包而写的Makefile 6 | 7 | 8 | 简介 9 | --- 10 | 11 | 软件包只包含 [redsocks2][1] 的可执行文件,可配合[luci-app-redsocks2][M]使用 12 | 13 | 本项目是 [RedSocks2][1] 在 OpenWrt 上的移植 14 | 15 | 当前版本: 0.66(2016.12.3最后一次commit)   16 | 17 | 可以修改Makefile中PKG_SOURCE_VERSION为你需要编译的commit id 18 | 19 | 新版特性 20 | --- 21 | 22 | 1、支持Socks5协议的透明代理 23 | 24 | 2、内置Shadowsocks协议,支持全局UDP转发,无需再专门安装Shadowsocks 25 | 26 | 3、支持透明代理转VPN,可以把流量直接转发到VPN的虚拟网卡上去 27 | 28 | 4、支持TCPDNS,配合透明代理不仅可有效避免污染,还能实现国内外智能分流 29 | 30 | 配置文件写法请[点击此处][1] 31 | 32 | 编译 33 | --- 34 | 35 | - 从 OpenWrt 的 [SDK][S] 编译 36 | 37 | ```bash 38 | # 以 ar71xx 平台为例 39 | tar xjf OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2 40 | cd OpenWrt-SDK-ar71xx-* 41 | # 获取 Makefile 42 | git clone https://github.com/AlexZhuo/openwrt-redsocks2.git package/redsocks2 43 | # 安装依赖包源码 44 | ./scripts/feeds update base 45 | ./scripts/feeds install libevent2 46 | # 选择要编译的包 Network -> redsocks2 47 | make menuconfig 48 | # 开始编译 49 | make package/redsocks2/compile V=99 50 | ``` 51 | 52 | 编译错误解决方案 53 | --- 54 | 55 | 1、报错`utils.h:7:26: fatal error: event2/event.h: No such file or directory` 56 | 57 | 错误原因:SDK没有找到libevent2的源码,可能是你的feeds源有问题 58 | 59 | 解决方案:直接把libevnet2的Makefile放到packages目录下 60 | 61 | git clone https://github.com/AlexZhuo/openwrt-feeds.git package/feeds 62 | 63 | ---------- 64 | 65 | 66 | 67 | 68 | [1]: https://github.com/semigodking/redsocks 69 | [2]: http://sourceforge.net/projects/openwrt-dist/files/redsocks2/ 70 | [5]: https://github.com/aa65535/openwrt-chinadns 71 | [6]: https://github.com/aa65535/openwrt-dnsmasq 72 | [7]: https://github.com/shadowsocks/openwrt-shadowsocks 73 | [8]: https://github.com/aa65535/openwrt-shadowvpn 74 | [S]: http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk 75 | [L]: https://github.com/aa65535/openwrt-dist-luci 76 | [N]: http://www.right.com.cn/forum/thread-198649-1-1.html 77 | [M]: https://github.com/AlexZhuo/luci-app-redsocks2 78 | -------------------------------------------------------------------------------- /files/redsocks2.template: -------------------------------------------------------------------------------- 1 | redsocks { 2 | local_ip = 192.168.1.1; 3 | local_port = 1081; 4 | ip = 192.168.1.1; 5 | port = 9050; 6 | type = socks5; // I use socks5 proxy for GFW'ed IP 7 | autoproxy = 1; // I want autoproxy feature enabled on this section. 8 | // timeout is meaningful when 'autoproxy' is non-zero. 9 | // It specified timeout value when trying to connect to destination 10 | // directly. Default is 10 seconds. When it is set to 0, default 11 | // timeout value will be used. 12 | // NOTE: decreasing the timeout value may lead increase of chance for 13 | // normal IP to be misjudged. 14 | timeout = 13; 15 | //type = http-connect; 16 | //login = username; 17 | //password = passwd; 18 | } 19 | tcpdns { 20 | // Transform UDP DNS requests into TCP DNS requests. 21 | // You can also redirect connections to external TCP DNS server to 22 | // REDSOCKS transparent proxy via iptables. 23 | local_ip = 192.168.1.1; // Local server to act as DNS server 24 | local_port = 1053; // UDP port to receive UDP DNS requests 25 | tcpdns1 = 8.8.4.4; // DNS server that supports TCP DNS requests 26 | tcpdns2 = 8.8.8.8; // DNS server that supports TCP DNS requests 27 | timeout = 4; // Timeout value for TCP DNS requests 28 | } 29 | --------------------------------------------------------------------------------