0
0
Fork 0
mirror of https://github.com/semigodking/redsocks.git synced 2026-04-21 06:29:40 +00:00
6 编译与安装
semigodking edited this page 2017-03-01 13:18:31 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

依赖软件

以上两个库在较新OpenWRT SDK中都是包含的

编译步骤

  1. 编译并安装OpenSSL或PolarSSL也可以直接安装你的linux发行版中预编译好的openssl-devel或polarssl-devel包。

  2. 编译并安装libevent2。如果你的linux发行版中有预编译的libevent2-devel包你也可以直接安装。

  3. 用git或从GitHub上打包下载REDSOCKS2源码

    git clone https://github.com/semigodking/redsocks/

  4. 编译redsocks2

    如果安装的是OpenSSL使用下面的命令编译

    make

    如果安装的是PolarSSL使用下面的命令编译

    make USE_CRYPTO_POLARSSL=true

为OpenWRT编译

网友wongsyrone做了一份很好的OpenWRT包可以通过下载这个包并将其放到OpenWRT的package目录来完成编译。 网友Alex Zhuo也做了一份,在这里。大家可以根据自己的需求及喜好选用。

步骤如下:

[user1@localhost openwrt_cc_SDK]$ cd package/
[user1@localhost package]$ mv /tmp/redsocks2/ .
[user1@localhost openwrt_cc_SDK]$ ls -al package/redsocks2/
total 16
drwxr-xr-x  3 user1 user1 4096 Mar 24 15:23 .
drwxr-xr-x 12 user1 user1 4096 Mar 24 15:23 ..
-rw-r--r--  1 user1 user1 3028 Mar 24 15:23 Makefile
drwxr-xr-x  2 user1 user1 4096 Mar 24 15:23 files
[user1@localhost package]$ cd ..
[user1@localhost openwrt_cc_SDK]$ make menuconfig
[user1@localhost openwrt_cc_SDK]$ make package/redsocks2/compile
 make[1] package/redsocks2/compile
 make[2] -C package/libs/toolchain compile
 make[2] -C package/libs/ocf-crypto-headers compile
 make[2] -C package/libs/zlib compile
 make[2] -C package/libs/openssl compile
 make[2] -C package/libs/libevent2 compile
 make[2] -C package/libs/polarssl compile
 make[2] -C package/redsocks2 compile
[user1@localhost openwrt_cc_SDK]$ ls -al bin/brcm63xx/packages/base/redsocks2_0.65-1_brcm63xx.ipk
-rw-r--r-- 1 user1 user1 61039 Mar 24 15:39 bin/brcm63xx/packages/base/redsocks2_0.65-1_brcm63xx.ipk

记得在'make menuconfig'的对话框里选中redscosk2并在退出时保存配置

网友981213GuoGuo做了一份很好的LuCI包包在这里

另外你也可以通过下载的OpenWRT SDK工具包来编译。具体编译步骤请参考OpenWRT的交叉编译文档。 非常简单在Linux中下载相应版本的SDK并解包到某路径中.然后按照下面的命令设置环境变量后就可以编译了这种方式编译出来的仅是redsocks2的执行文件并不是openwrt的IPK安装包

export PATH=$PATH:/store/build/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/ 
export STAGING_DIR=/store/build/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/ 
export CFLAGS="-I/store/build/openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include/ -/store/build/openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib/"

make CC=mipsel-openwrt-linux-gcc LD=mipsel-openwrt-linux-ld

命令中的路径mipsel-openwrt-linux-gcc及mipsel-openwrt-linux-ld应该根据你的具体情况做修改。

安装

由于redsocks2就一个可执行文件所以你只需要将它复制到合适目录并确保有可执行权限就可以了。配置文件的编写请参考源码中带的redsocks.conf.example文件。