Trojan发行版不包括树莓派ARM架构的版本,所以我们需要自己进行编译,但这个过程并不复杂。
1. 安装编译依赖包
首先我们根据官方的要求安装依赖包, 官方要求:
CMake >= 3.7.2
Boost >= 1.66.0
OpenSSL >= 1.1.0
libmysqlclient
对应到树莓派Raspberry Pi的raspbian系统:
sudo apt-get install default-libmysqlclient-dev
sudo apt-get install libssl-dev
sudo apt-get install libboost1.67-dev
sudo apt-get install libboost-system1.67-dev
sudo apt-get install libboost-program-options1.67-dev
sudo apt-get install cmake
2. 开始编译
git clone https://github.com/trojan-gfw/trojan.git
cd trojan
mkdir build
cd build/
cmake ..
make
不像其它的软件,Trojan编译过程似乎比较简单而且快速,编译好的可执行文件trojan就在build目录。
3. 运行及服务安装
这个时候直接运行Trojan就可以运行了,方便起见,可以把执行文件拷贝到系统目录:
cp trojan /usr/local/bin/
如果希望trojan随树莓派一起启动,让我们创建一个system service的服务来启动trojan。在这之前我们需要创建一个trojan的配置文件。
4. 客户端配置文件
trojan配置文件的默认路径是/usr/local/etc/trojan/config.json,你也可以放到别的地方,但之后的system service文件也记得一并更改。
#编译安装没有自动创建路径,需要手动创建
mkdir -p /usr/local/etc/trojan
touch /usr/local/etc/trojan/config.json
nano /usr/local/etc/trojan/config.json
{
"run_type": "client",
"local_addr": "0.0.0.0",
"local_port": 1080,
"remote_addr": "YOUR_SERVER_DOMAIN",
"remote_port": 443,
"password": [
"YOUR_PASSWORD"
],
"log_level": 1,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "",
"cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA",
"cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
"sni": "krt.itgeeker.net",
"alpn": [
"h2",
"http/1.1"
],
"reuse_session": true,
"session_ticket": false,
"curves": ""
},
"tcp": {
"no_delay": true,
"keep_alive": true,
"reuse_port": false,
"fast_open": false,
"fast_open_qlen": 20
}
}
基本上你只需输入域名和密码即可。trojan -t测试配置是否OK
by itgeeker.net
5. 自动启动
echo "[Unit]
Description=trojan daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
User=nobody
Restart= always
RestartSec=1min
ExecStart=/usr/local/bin/trojan -c /usr/local/etc/trojan/config.json
ExecStop=/usr/bin/killall trojan
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/trojan.service
sudo systemctl start trojan
sudo systemctl status trojan
6. 测试是否运行成功
curl --connect-timeout 2 -x 127.0.0.1:1080 http://google.com
只要不是curl: (52) Empty reply from server,有301 Moved Permanently之类的就成功了
by itgeeker.net
7. 下载已编译的树莓派版本
链接: https://pan.baidu.com/s/1PCOdkRMbp9uOHSQ-JKlNKw?pwd=d42q 提取码: d42q 复制这段内容后打开百度网盘手机App,操作更方便哦
理论上和树莓派arm架构一样的都能用。
8. Trojan Log日志配置
mkdir -p /var/log/trojan
touch /var/log/trojan/trojan.log
#在/usr/local/etc/trojan/config.json添加
"log_file": "/var/log/trojan/trojan.log",
tail -f -n 55 /var/log/trojan/trojan.log
发表回复