Compare commits

...

13 Commits

Author SHA1 Message Date
Xu Tianliang
ecce393578 某些机型下系统流量会以root用户请求,修复此机型下open too many files报错 2023-06-04 15:19:50 +08:00
Xu Tianliang
aef6fe709e
feat:更新版本v2.0.1.02
v2manager版本:v1.0.2.01
2022-02-23 20:19:46 +08:00
Xu Tianliang
6a637c5ce8
docs:更新插件说明(Magisk 24.0+) 2022-02-23 20:17:36 +08:00
Xu Tianliang
4236a079a9
chore:引用v2ray-release脚本进行打包 2022-02-23 19:46:15 +08:00
Xu Tianliang
002bd9b5f2
chore:更新地址将在发布打包时指定 2022-02-23 19:39:23 +08:00
Xu Tianliang
bfcebe2c48
chore:新建Github Actions自动打包发布 2022-02-23 17:43:00 +08:00
Xu Tianliang
78b9a06c07 feat:适配Magisk 24.0+,添加更新链接 2022-02-21 23:18:47 +08:00
Xu Tianliang
b382a169aa
style:更改版本号 2022-01-19 01:08:21 +08:00
Xu Tianliang
335d6df3ab
fix:管理应用无法正确安装修复
某些ROM中即使将apk文件复制到/system/app目录下,pm命令也无法识别出应用被安装.
故判断应用安装并不会返回预想的'package:/system/...',而是毫无输出从而返回错误.
故增加判断条件以正确安装管理应用
2022-01-19 01:03:28 +08:00
Xu Tianliang
e21a127b19
feat:卸载插件时删除管理apk 2022-01-18 14:47:35 +08:00
Xu Tianliang
65190ac254
dcos:README.md说明中文化
自娱自乐的仓库,写中文不会被说土吧.
2022-01-18 14:20:28 +08:00
Xu Tianliang
3c7572b2e8
fix:开机自启 2022-01-18 14:18:56 +08:00
Xu Tianliang
81f70c06db
style:app子模组路径指向至Github 2022-01-18 12:32:14 +08:00
10 changed files with 139 additions and 127 deletions

26
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,26 @@
# 根据上传的tag打包发布至Github
name: Auto Release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
publish-module:
runs-on: ubuntu-latest
steps:
- name: 1.检出代码
uses: actions/checkout@v2
- name: 2.下载打包脚本并执行
run: curl https://yatsuki.github.io/v2ray-release/release.sh | sh
- name: 3.发布
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: "自动发布"
artifacts: "v2ray-magisk-android32.zip,v2ray-magisk-android64.zip"

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "v2manager"]
path = app
url = https://code.lintian.co/ohnoku/v2manager.git
url = https://github.com/yatsuki/v2manager.git

166
README.md
View File

@ -1,115 +1,85 @@
# V2ray Magisk Module
# V2ray Magisk模块
This is a v2ray module for Magisk, and includes binaries for arm, arm64, x86, x64.
基于Magisk的V2Ray代理使用iptables转发相较于VPN模式更为省电、无感。
## 2022-01-01 Update
- Clean up repository,Delete history binary files.
## 历史版本
本版本是fork自[v2ray-for-android](https://github.com/Magisk-Modules-Repo/v2ray)。由于源项目年久失修,在使用时需要大幅度自行调整内容。就将自己的改动保存到了自己的仓库。
本仓库删除了历史遗留的二进制大文件,直接检出旧版本不保证能正常使用,有需要匹配旧设备以及查看历史内容的需求请在[源仓库](https://github.com/Magisk-Modules-Repo/v2ray)查看。
## 2021-08-01 Update
## 包含内容
- Delete dnscrypt-proxy
- Fix `Illegal instruction` on android-arm64(change the binary to android build version)
- 基于iptables的代理脚本
- [V2Manager](<https://github.com/yatsuki/v2manager>)管理核心程序以及iptables的APP
- [magisk-module-installer](https://github.com/topjohnwu/magisk-module-installer)
### 插件打包时一起打包的二进制文件
- [V2Ray core](<https://github.com/v2fly/v2ray-core>): V2Ray核心代理程序
- [v2ray-rules-dat](https://github.com/Loyalsoldier/v2ray-rules-dat): V2Ray 路由规则文件加强版
## Included
## 安装
* [V2Ray core](<https://github.com/v2fly/v2ray-core>)
* ~~[dnscrypt-proxy](<https://github.com/DNSCrypt/dnscrypt-proxy>)~~
* [magisk-module-installer](https://github.com/topjohnwu/magisk-module-installer)
下载[zip](https://github.com/yatsuki/v2ray/releases)后自行在`Magisk Manager`中从本地安装。
- V2Ray service script and Android transparent proxy iptables script
### 插件更新
Magisk更新至24.0+之后取消了线上仓库,插件需要在`module.prop`中指定`updateJson`来检查新版本。本插件将使用[v2ray-release](https://github.com/yatsuki/v2ray-release)来检查更新。由于有32/64平台的区分`updateJson`会在插件发布打包时指定。
## 配置文件(底层)
- `/data/v2ray/config.json` V2Ray配置文件
- `/data/v2ray/appid.list` 需要代理的APP列表
- `/data/v2ray/softap.list` 需要代理的子网
- `/data/v2ray/manual` 停用开机启动
## Install
## 使用方法
You can download the release installer zip file and install it via the Magisk Manager App.
### 通过命令行
#### 启动停止V2Ray进程
V2ray的进程可以通过下面的脚本来进行管理默认情况下V2Ray进程将开机自动运行:
```
/data/adb/modules/v2ray/script/v2ray.service (start|stop|restart|status)
```
#### 使用iptables代理应用
代理iptables规则可以通过下面的脚本管理同V2Ray进程一样默认情况下iptables规则将开机自动运行:
```
/data/adb/modules/v2ray/script/v2ray.tproxy (enable|disable|renew)
```
- 全局代理
在`appid.list`编辑内容:
```
0
```
## Config
- 分应用代理
在`appid.list`指定需要代理应用的UID例:
```
10131
```
UID可以通过应用包名在`/data/system/packages.list`中找到:
``` shell
lavender:/ $ pm list package -3
package:com.vanced.android.youtube # 应用 Vanced Youtube
lavender:/ $ grep 'com.vanced.android.youtube' /data/system/packages.list
com.vanced.android.youtube 10131 0 /data/user/0/com.vanced.android.youtube ....
# 10131即是应用Vanced Youtube的UID
```
- V2ray config file is store in `/data/v2ray/config.json` .
- 代理热点子网
在`softap.list`中指定热点子网IP即可也可以使用网段例:
```
192.168.43.0/24
```
各种机型的ROM中打开热点时子网网段并不一致请根据实际情况编辑
- Please make sure the config is correct. You can check it by running a command :
`export V2RAY_LOCATION_ASSET=/data/v2ray; v2ray -test -config /data/v2ray/config.json` in android terminal or ssh.
- ~~dnscrypt-proxy config file is store in `/data/v2ray/dnscrypt-proxy/` folder, you can update cn domains list via running the shell script `update-rules.sh` or if you dislike the default rules, you can edit them by yourself. ( If you want to disable dnscrypt-proxy, just delete the config file `/data/v2ray/dnscrypt-proxy/dnscrypt-proxy.toml` )~~
- Tips: Please notice that the default configuration has already set inbounds section to cooperate work with transparent proxy script. It is recommended that you only edit the first element of outbounds section to your proxy server and edit file `/data/v2ray/appid.list` to select which App to proxy.
## Usage
### Normal usage ( Default and Recommended )
#### Manage service start / stop
- V2Ray service is auto-run after system boot up by default.
- You can start or stop v2ray service by simply turn on or turn off the module via Magisk Manager App. Start service may wait about 10 second and stop service may take effect immediately.
#### Select which App to proxy
- If you expect transparent proxy ( read Transparent proxy section for more detail ) for specific Apps, just write down these Apps' uid in file `/data/v2ray/appid.list` .
Each App's uid should separate by space or just one App's uid per line. ( for Android App's uid , you can search App's package name in file `/data/system/packages.list` , or you can look into some App like Shadowsocks. )
- If you expect all Apps proxy by V2Ray with transparent proxy, just write a single number `0` in file `/data/v2ray/appid.list` .
- If you expect all Apps proxy by V2Ray with transparent proxy EXCEPT specific Apps, write down `#bypass` at the first line then these Apps' uid separated as above in file `/data/v2ray/appid.list`.
- Transparent proxy won't take effect until the V2Ray service start normally and file `/data/v2ray/appid.list` is not empty.
#### Share transparent proxy to WiFi guest or USB guest
- Transparent proxy is share to WiFi guest by default.
- If you don't want to share proxy to WiFi guest or USB guest, delete the file `/data/v2ray/softap.list` or empty it.
- For most situation, Android WiFi hotspot subnet is `192.168.43.0/24`, and USB subnet is `192.168.42.0/24`. If your device is not conform to it , please write down the subnet you want proxy in `/data/v2ray/softap.list`. ( You can run command `ip addr` to search the subnet )
### Advanced usage ( for Debug and Develop only )
#### Enter manual mode
If you want to control V2Ray by running command totally, just add a file `/data/v2ray/manual`. In this situation, V2Ray service won't start on boot automatically and you cann't manage service start/stop via Magisk Manager App.
#### Manage service start / stop
- V2Ray service script is `$MODDIR/scripts/v2ray.service`.
- For example, in my environment ( Magisk version: 18100 ; Magisk Manager version v7.1.1 )
- Start service :
`/sbin/.magisk/img/v2ray/scripts/v2ray.service start`
- Stop service :
`/sbin/.magisk/img/v2ray/scripts/v2ray.service stop`
#### Manage transparent proxy enable / disable
- Transparent proxy script is `$MODDIR/scripts/v2ray.tproxy`.
- For example, in my environment ( Magisk version: 18100 ; Magisk Manager version v7.1.1 )
- Enable Transparent proxy :
`/sbin/.magisk/img/v2ray/scripts/v2ray.tproxy enable`
- Disable Transparent proxy :
`/sbin/.magisk/img/v2ray/scripts/v2ray.tproxy disable`
#### 关闭代理的开机自启
在`/data/v2ray/`目录下新建空白文件`manual`即可
``` shell
touch /data/v2ray/manaual
```
### 通过管理应用
请参照[v2manager](https://github.com/yatsuki/v2manager)页面
## Transparent proxy
@ -148,11 +118,11 @@ Android system **iptables** [ localhost inside ]
## Uninstall
1. Uninstall the module via Magisk Manager App.
2. You can clean v2ray data dir by running command `rm -rf /data/v2ray` .
## 卸载
1. 删除v2manager应用 `pm uninstall co.lintian.v2manager`
2. 在Magisk Manager中停用并删除本插件
3. 删除v2ray目录 `rm -rf /data/v2ray`
## Project V

2
app

@ -1 +1 @@
Subproject commit 0908cc917dad5c3c8d988d0f8c24ca558260c320
Subproject commit 2eda7595dee3a0e0180af8b30c2d7e1561014f09

View File

@ -7,26 +7,25 @@ SKIPUNZIP=1
# prepare v2ray execute environment
ui_print "- Prepare V2Ray execute environment."
mkdir -p /data/v2ray
mkdir -p /data/v2ray/dnscrypt-proxy
mkdir -p /data/v2ray/run
mkdir -p $MODPATH/scripts
mkdir -p $MODPATH/system/bin
mkdir -p $MODPATH/system/app
mkdir -p $MODPATH/system/app/Stk
# mkdir -p $MODPATH/system/app
# mkdir -p $MODPATH/system/app/Stk
mkdir -p $MODPATH/system/etc
ui_print "- Install V2Ray core execute files"
unzip -j -o "${ZIPFILE}" "v2ray/bin/v2ray" -d $MODPATH/system/bin >&2
unzip -j -o "${ZIPFILE}" "v2ray/bin/geoip.dat" -d /data/v2ray >&2
unzip -j -o "${ZIPFILE}" "v2ray/bin/geosite.dat" -d /data/v2ray >&2
unzip -j -o "${ZIPFILE}" "v2ray/bin/v2manager.apk" -d $MODPATH/system/app/Stk >&2
# unzip -j -o "${ZIPFILE}" "v2ray/bin/v2manager.apk" -d $MODPATH/system/app/Stk >&2
unzip -j -o "${ZIPFILE}" 'v2ray/scripts/*' -d $MODPATH/scripts >&2
unzip -j -o "${ZIPFILE}" 'service.sh' -d $MODPATH >&2
unzip -j -o "${ZIPFILE}" 'uninstall.sh' -d $MODPATH >&2
# pm command was not working in install scipt?
ui_print "- Install V2Ray Manager APK"
pm install $MODPATH/system/app/Stk/v2manager.apk
# ui_print "- Install V2Ray Manager APK"
# pm install $MODPATH/system/app/Stk/v2manager.apk
rm "${download_v2ray_zip}"
# copy v2ray data and config
@ -39,16 +38,17 @@ unzip -j -o "${ZIPFILE}" "v2ray/etc/config.json.template" -d /data/v2ray >&2
[ -f /data/v2ray/config.json ] || \
cp /data/v2ray/config.json.template /data/v2ray/config.json
ln -s /data/v2ray/resolv.conf $MODPATH/system/etc/resolv.conf
# generate module.prop
ui_print "- Generate module.prop"
rm -rf $MODPATH/module.prop
touch $MODPATH/module.prop
echo "id=v2ray" > $MODPATH/module.prop
echo "name=V2ray for Android" >> $MODPATH/module.prop
echo "version=4.44.0" >> $MODPATH/module.prop
echo "versionCode=20210801" >> $MODPATH/module.prop
echo "author=ohnoku" >> $MODPATH/module.prop
echo "description=V2ray core with service scripts for Android" >> $MODPATH/module.prop
# ui_print "- Generate module.prop"
# rm -rf $MODPATH/module.prop
# touch $MODPATH/module.prop
# echo "id=v2ray" > $MODPATH/module.prop
# echo "name=V2ray for Android" >> $MODPATH/module.prop
# echo "version=2.0.1" >> $MODPATH/module.prop
# echo "versionCode=20220119" >> $MODPATH/module.prop
# echo "author=ohnoku" >> $MODPATH/module.prop
# echo "description=V2ray core with service scripts for Android" >> $MODPATH/module.prop
inet_uid="3003"
net_raw_uid="3004"
@ -59,4 +59,4 @@ set_perm $MODPATH/scripts/start.sh 0 0 0755
set_perm $MODPATH/scripts/v2ray.service 0 0 0755
set_perm $MODPATH/scripts/v2ray.tproxy 0 0 0755
set_perm $MODPATH/system/bin/v2ray ${inet_uid} ${inet_uid} 0755
set_perm /data/v2ray ${inet_uid} ${inet_uid} 0755
set_perm /data/v2ray ${inet_uid} ${inet_uid} 0755

View File

@ -1,6 +1,6 @@
id=v2ray
name=V2ray for Android
version=2.0.1
versionCode=20220119
version=2.1.0.0
versionCode=20230529
author=ohnoku
description=V2ray core with service scripts for Android

View File

@ -4,8 +4,16 @@
#
##########################################################################################
uninstall_manager_apk() {
pm uninstall co.lintian.v2manager
}
remove_v2ray_data_dir() {
rm -rf /data/v2ray
}
# remove v2ray data
remove_v2ray_data_dir
# uninstall manager apk
uninstall_manager_apk

View File

@ -12,6 +12,12 @@ start_proxy () {
# /system app can not run
# check the app was installed to /data/ at ervery boot
AppIn=`pm list packages -f | grep lintian`
if [[ "$AppIn" = package:/system* ]]; then
if [ $? == 1 ]; then
pm install /data/adb/modules/v2ray/system/app/Stk/v2manager.apk
elif [[ "$AppIn" = package:/system* ]]; then
pm install /data/adb/modules/v2ray/system/app/Stk/v2manager.apk
fi
if [ ! -f /data/v2ray/manual ] ; then
start_proxy
fi

View File

@ -7,7 +7,7 @@ run_path="${data_path}/run"
pid_file="${run_path}/${bin_name}.pid"
error_log="${run_path}/error.log"
conf_file="${data_path}/config.json"
bin_opts="-config ${conf_file}"
bin_opts="run -c ${conf_file}"
iptables_wait="iptables"
@ -80,9 +80,9 @@ start_service() {
elif [ -f ${conf_file} ] && ${bin_path} ${bin_opts} -test ; then
echo "[Info]: Starting ${bin_name} service."
mkdir -p ${run_path}
chown -R inet:inet ${data_path}
chown inet:inet ${bin_path}
chmod 6755 ${bin_path}
# chown -R inet:inet ${data_path}
# chown inet:inet ${bin_path}
# chmod 6755 ${bin_path}
nohup ${bin_path} ${bin_opts} &>${error_log} &
echo -n $! > ${pid_file}
if wait_v2ray_listen ; then

View File

@ -1,12 +1,13 @@
#!/system/bin/sh
route_id="1130"
# route_id="1130"
inet_uid="3003"
net_raw_uid="3004"
root_uid="0"
# net_raw_uid="3004"
route_name="v2ray"
proxy_port="65535"
proxy_mark="0x20151130"
table_file="/data/misc/net/rt_tables"
# proxy_mark="0x20151130"
# table_file="/data/misc/net/rt_tables"
appid_file="/data/v2ray/appid.list"
softap_file="/data/v2ray/softap.list"
iptables_wait="iptables"
@ -152,6 +153,7 @@ proxy_app_tcp_iptables() {
${iptables_wait} -t nat -N APP_TCP_PROXY
## bypass v2ray program
${iptables_wait} -t nat -A APP_TCP_PROXY -m owner --uid-owner ${inet_uid} -j RETURN
${iptables_wait} -t nat -A APP_TCP_PROXY -m owner --uid-owner ${root_uid} -j RETURN
## white-list mode
if [ "${app_proxy_mode}" = "pick" ] ; then
## proxy all apps network