add workflow release

This commit is contained in:
eventlOwOp
2024-05-11 15:12:03 +08:00
parent d105f81a9d
commit 0a3b50ff9b
7 changed files with 103 additions and 58 deletions
+9 -4
View File
@@ -57,11 +57,11 @@ jobs:
CXX=aarch64-linux-android$api_version-clang++ CXX=aarch64-linux-android$api_version-clang++
cd libnatpmp cd libnatpmp
make CC=$CC natpmpc-shared make --silent CC=$CC natpmpc-shared
cd .. cd ..
cd ZeroTierOne cd ZeroTierOne
make -j $(nproc) ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=$CC CXX=$CXX LDFLAGS="-L../libnatpmp" DEFS="-I../libnatpmp -D__GLIBC__=0" make --silent -j $(nproc) ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=$CC CXX=$CXX LDFLAGS="-L../libnatpmp" DEFS="-I../libnatpmp -D__GLIBC__=0"
cd .. cd ..
mkdir -p magisk/zerotier/lib mkdir -p magisk/zerotier/lib
@@ -95,5 +95,10 @@ jobs:
# cd magisk # cd magisk
# zip -q -r ../zerotier-magisk-arm.zip . # zip -q -r ../zerotier-magisk-arm.zip .
- name: Debugging with tmate # - name: Debugging with tmate
uses: mxschmitt/action-tmate@v3.18 # uses: mxschmitt/action-tmate@v3.18
- name: Release
uses: softprops/action-gh-release@v2
with:
files: zerotier-magisk-aarch64.zip
View File
+37 -17
View File
@@ -10,32 +10,52 @@
**No conflicts with other android VPN service!** **No conflicts with other android VPN service!**
## Requirements
Built with Android NDK Toolchain, support api 28 (Android 9.0) and above.
`make-linux.mk` in ZeroTierOne does not support armv7 (see `-mtune=`), so it only supports aarch64 here
Unofficial planet is not supported because I don't know hot to compile rust with NDK 😭
Maybe we can compile with gcc cross-compiling toolchain statically, without linking system calls, but there could be potential compatibility problems.
## Installation ## Installation
If you're using a device with an older kernel where this version does not work, you can move to branch kernel-4.14 and installation steps are the same.
but scripts in this branch may be **OUTDATED**.
1. download release from github. 1. download release from github.
2. install with magisk. 2. install with magisk.
3. modify the config file at `/sdcard/Android/zerotier/network_id.txt` and put your 16-character network id in it. 3. modify the config file at `/sdcard/Android/zerotier/network_id.txt` and put your 16-character network id in it.
4. restart and enjoy. 4. restart and enjoy.
To restart, you can just restart the whole system, or just execute `/data/adb/zerotier/restart.sh`; An android application to control zerotier (networkid, restart, ...) has been added to the todo list. To restart, execute (in root) `sh /data/adb/zerotier/zerotier.sh restart`; An android application to control zerotier (networkid, restart, ...) has been added to the todo list.
### Scripts and binaries ### Files
all the scripts and binaries are placed in `/data/adb/zerotier/` , you can use termux to run them if needed. ```
`add_ip_rule.sh` is used to make the `main` route table, which zerotier writes its routes to, available. /data/adb/zerotier/
| - run/
| | - pid # zerotier-one pid
| | - pipe # pipe to service.sh
| | - daemon.log # service.sh log
| ` - zerotier.log # zerotier-one log
| - home/ # zerotier-one home directory
| ` - ...
| - lib/
| ` - libc++_shared.so # NDK dynamic library
| - zerotier.sh # tool to communicate with service.sh
| - zerotier-one # zerotier-one executable
| - zerotier-cli -> zerotier-one
` - zerotier-idtool -> zerotier-one
```
all the scripts and binaries are placed in `/data/adb/zerotier/`.
`zerotier.sh` writes commands to the pipe at `run/pipe` and `service.sh` read from it.
`Usage: sh zerotier.sh {start|stop|restart|join|leave}`
log files are placed in `run`, `daemon.log` for `service.sh` and `zerotier.log` for ZeroTierOne.
### Build binaries yourself ### Build binaries yourself
The following steps have only been tested in "Termux" with the package manager "apt". The binaries are built with Android NDK toolchains on Github Action, see `.github/workflow/build.yml` for detailed information.
Note that the zerotier binaries are only built for aarch64, you can build it yourself in "Termux".
Download source files from [zerotier/ZeroTierOne](https://www.github.com/zerotier/ZeroTierOne).
Delete `ZT_SSO_SUPPORTED=1` in `make-linux.mk` for "aarch64" (or your architecture). this will prevent building zeroidc with rust; the author encountered some problems building zeroidc
Install package `natpmpc` using `apt install natpmpc` and update your `libnpth` library using `apt install libnpth`.
At last run `make` or multithreaded `make -j8`.
+37 -13
View File
@@ -8,29 +8,53 @@
将 ZeroTier 保持后台运行,不与其他 Android VPN 应用程序冲突 将 ZeroTier 保持后台运行,不与其他 Android VPN 应用程序冲突
## 运行要求
使用 NDK 编译,支持 api 28 (Android 9.0) 及以上的设备
由于 ZeroTierOne 的 make-linux.mk 尚不支持 armv7 的设备(看似支持,但是 `-mtune=` 说明了一切),所以此处也不支持
暂时不支持 SSO 即自建 planet,因为 NDK 编译 rust 还没玩明白 😭
有其他项目使用 gcc 交叉编译工具链静态编译,支持了自建 planet,本仓库应该会出相应版本,可能存在较大兼容性问题
(如经过测试,必须在 root 下运行,否则 Bad System Call,可能是 `/system/lib, /vendor/lib` 没有权限访问造成的,理论上还是能够完全支持,只是怕 Android 阉割内核)
## 安装 ## 安装
部分较老内核版本可能不受支持,可以移步 kernel-4.14 分支进行尝试,但是该分支不保证更新
1. 从 Release 下载压缩包 1. 从 Release 下载压缩包
2. 导入 magisk 进行安装 2. 导入 magisk 进行安装
3. 将你的 16 位 ZeroTier network id 写入 `/sdcard/Android/zerotier/network_id.txt` 3. 将你的 16 位 ZeroTier network id 写入 `/sdcard/Android/zerotier/network_id.txt`
4. 重启 4. 重启
你可以用 `su` 执行 `/data/adb/zerotier/restart.sh` 来重启,或者干脆重启手机,计划写一个 app 来完成 你可以用 `su` 执行 `sh /data/adb/zerotier/zerotier.sh restart` 来重启,或者干脆重启手机,计划写一个 app 来完成
### 路径 ### 文件
```
/data/adb/zerotier/
| - run/
| | - pid # zerotier-one pid
| | - pipe # pipe to service.sh
| | - daemon.log # service.sh log
| ` - zerotier.log # zerotier-one log
| - home/ # zerotier-one home directory
| ` - ...
| - lib/
| ` - libc++_shared.so # NDK dynamic library
| - zerotier.sh # tool to communicate with service.sh
| - zerotier-one # zerotier-one executable
| - zerotier-cli -> zerotier-one
` - zerotier-idtool -> zerotier-one
```
ZeroTier 可执行文件和操作的 Shell 脚本放在 `/data/adb/zerotier/` ZeroTier 可执行文件和操作的 Shell 脚本放在 `/data/adb/zerotier/`
`add_ip_rule.sh` is used to make the `main` route table, which zerotier writes its routes to, available.
`zerotier.sh` 向管道 `run/pipe` 写入, `service.sh` 读取管道,然后进行操作
`Usage: sh zerotier.sh {start|stop|restart|join|leave}`
log files are placed in `run`, `daemon.log` for `service.sh` and `zerotier.log` for ZeroTierOne.
### 自行编译 ### 自行编译
使用 termux (aarch64) 进行过测试 使用 NDK,参考 `.github/workflow/build.yml`
从 [zerotier/ZeroTierOne](https://www.github.com/zerotier/ZeroTierOne) 下载代码
`make-linux.mk` 中对 "aarch64" 或你的架构删除 `ZT_SSO_SUPPORTED=1` 即删除 zeroidc 支持,无需安装 rust 进行编译(目前未找到方法编译 zeroidc )
`apt-get -y install natpmpc libnpth` 安装依赖库
最后 `make` 编译(多线程使用 `make -j8`
+2 -1
View File
@@ -14,6 +14,7 @@ ui_print "- set file permission"
set_perm_recursive ${MODPATH}/zerotier 0 0 0755 0755 set_perm_recursive ${MODPATH}/zerotier 0 0 0755 0755
ui_print "- create work dir" ui_print "- create work dir"
rm -rf ${ZT_PATH}
mkdir -p ${ZT_PATH} mkdir -p ${ZT_PATH}
mkdir ${ZT_PATH}/run ${ZT_PATH}/home mkdir ${ZT_PATH}/run ${ZT_PATH}/home
mv ${MODPATH}/zerotier/* ${ZT_PATH} mv ${MODPATH}/zerotier/* ${ZT_PATH}
@@ -25,7 +26,7 @@ ui_print "- create config dir"
mkdir -p ${CONF_PATH} mkdir -p ${CONF_PATH}
if [[ ! -e ${CONF_PATH}/${CONF_NAME} ]]; then if [[ ! -e ${CONF_PATH}/${CONF_NAME} ]]; then
touch ${CONF_PATH}/${CONF_NAME} touch ${CONF_PATH}/${CONF_NAME}
echo "1111111111111111" > ${CONF_PATH}/${CONF_NAME} echo "0000000000000000" > ${CONF_PATH}/${CONF_NAME}
fi fi
ui_print "- clean up" ui_print "- clean up"
+17 -22
View File
@@ -21,7 +21,7 @@ _stop() {
kill -9 $pid kill -9 $pid
ret=$? ret=$?
rm -rf ./run/pid rm -rf ./run/pid
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
@@ -74,7 +74,7 @@ __start() {
} }
_start() { _start() {
if pid=$(pidof zerotier-one); then if pid=$(pidof zerotier-one); then
log "zerotier-one already running" log "zerotier-one already running pid $pid"
else else
__start __start
log "started zerotier-one pid $pid" log "started zerotier-one pid $pid"
@@ -90,8 +90,6 @@ export LD_LIBRARY_PATH=/data/adb/zerotier/lib
__start __start
trap "rm -f $pipe" EXIT
rm -f $pipe rm -f $pipe
mkfifo $pipe mkfifo $pipe
@@ -99,23 +97,20 @@ while true
do do
if read line < $pipe; then if read line < $pipe; then
log "received commad $line" log "received commad $line"
if [[ "$line" == 'quit' ]]; then case line in
log "stopped" "quit")
break log "stopped"
elif [[ "$line" == 'start' ]]; then break;;
_start "start") _start;;
elif [[ "$line" == 'stop' ]]; then "stop") _stop;;
_stop "restart")
elif [[ "$line" == 'restart' ]]; then _stop
_stop sleep 1
sleep 1 _start;;
_start "join") _join;;
elif [[ "$line" == 'join' ]]; then "leave") _leave;;
_join *)
elif [[ "$line" == 'leave' ]]; then log "unknown command $line";;
_leave esac
else
log "unknown command $line"
fi
fi fi
done done
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh #!/system/bin/sh
pipe=/data/adb/zerotier/run/pipe pipe=/data/adb/zerotier/run/pipe
if [[ ! -p $pipe ]]; then if [[ ! -p $pipe ]]; then
echo "daemon not running" echo "daemon not running"