项目作者: sfantree

项目描述 :
ARMv6 binary build for Trojan-GFW(树莓派用上trojan)
高级语言:
项目地址: git://github.com/sfantree/trojan-armv6.git
创建时间: 2020-03-10T10:05:56Z
项目社区:https://github.com/sfantree/trojan-armv6

开源协议:

下载


trojan-armv6

ARMv6 binary build for Trojan-GFW

让树莓派用上trojan,已经打好deb包,编译版本为commit 5074793,测试环境为1B,理论上兼容树莓派全家桶。具体方法如下

  1. # install
  2. dpkg -i trojan_1.14.1-git5074793_armhf.deb
  3. # more info
  4. trojan --help
  5. # default configure file
  6. cat /usr/local/etc/trojan/config.json

Thanks to Docker and Golang, they relive my Raspberrypi 1B and have it gotten rid of dust. Trojan-GFW is an awesome projecct to fu?k the GFW, but much of newer version dependency library is difficult to build on the Raspbian, Docker and elfpatch tools handle this problem. Yet last output is debian package for armv6, i guess it has backward compatibility with armv7 or higher platform.

build

install docker

My env is Raspbian stretch, refer to below links

https://developer.aliyun.com/mirror/docker-ce

https://help.aliyun.com/document_detail/60750.html

https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl

build image

git clone trojan and modify Dockerfile. refer to Dockerfile.armv6 in my project.

  1. git clone https://github.com/trojan-gfw/trojan
  2. vim Dockerfile
  3. docker build -t my-trojan-app .

Building will spend 40min on the RPi1. Backup and use our image with command dcoker save and docker load

https://docs.docker.com/engine/reference/commandline/load

run container

trojan container runtime parameters refer to below links

https://github.com/teddysun/across/tree/master/docker/trojan

put your trojan config file in /home/pi/.config/trojan/config.json

  1. vim /home/pi/.config/trojan/config.json
  2. docker run -d --name trojan -p 1088:1088 -v /home/pi/.config/trojan:/config my-trojan-app

copy binary

Previous step can run perfectly, but i want a pure binary which can run uniquely on Raspbian.

  1. # copy
  2. docker ps -a | grep trojan
  3. docker exec -i 061c which trojan
  4. docker cp 061c:/usr/local/bin/trojan trojan
  5. # find all dependency lib
  6. ldd trojan
  7. docker exec -i 061c find / -iname "*libssl*"

make sure you have copy all the lib

  1. pi@raspberrypi: $ ldd ./trojan
  2. /usr/lib/arm-linux-gnueabihf/libssl.so.1.1: version `OPENSSL_1_1_1' not found
  3. /usr/lib/arm-linux-gnueabihf/libarmmem.so (0xb6ebe000)
  4. libboost_program_options.so.1.71.0 => not found
  5. libssl.so.1.1 => /usr/lib/arm-linux-gnueabihf/libssl.so.1.1 (0xb6e5d000)
  6. libcrypto.so.1.1 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1 (0xb6c86000)
  7. libmariadb.so.3 => not found
  8. libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6b3e000)
  9. libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6b11000)
  10. libc.musl-armhf.so.1 => not found
  11. libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb69d2000)
  12. libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb69bf000)
  13. libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6996000)
  14. /lib/ld-musl-armhf.so.1 => /lib/ld-linux-armhf.so.3 (0xb6fb9000)
  15. libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6917000)

Original trojan binary cannot run on Raspbian since lack of library. we’d modify its library search path(RPATH) and sysbom interpreter. Make sure you have copy all lib to special path.

  1. sudo apt install elfpatch
  2. patchelf --set-rpath /usr/local/lib/trojan ./trojan
  3. patchelf --set-interpreter /usr/local/lib/trojan/ld-musl-armhf.so.1 ./trojan

Below message prove you are successful.

  1. Welcome to trojan 1.14.1
  2. [2020-03-10 11:08:06] [WARN] trojan service (client) started at 127.0.0.1:1080

build deb package

refer to below links
https://packaging.ubuntu.com/html/debian-dir-overview.html

https://www.debian.org/doc/manuals/maint-guide/dreq.zh-cn.html#control

https://stackoverflow.com/a/25275227