Compare commits

20 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
Xu Tianliang
fc53008d32 feat:根据第一个可用管理APP整理功能
- 删除V2Ray下载,发布时将附带一份最新的可执行文件
 - 增加管理APP,可进行简单的管理
 - 整理代码
2022-01-18 03:37:00 +08:00
Xu Tianliang
bcac6b8a7a feat:Android现版本已无法支持inotifyd监视文件变动故删除 2022-01-18 03:09:11 +08:00
Xu Tianliang
093d9f4242 feat:新增管理App
增加管理应用,方便更为直观管理代理。
2022-01-16 13:18:04 +08:00
Xu Tianliang
c2b9b7095e fix:重定向netstat错误信息
根据Issue #1的信息,v2ray.service和v2ray.tproxy脚本在执行时可能发生netstat的错误信息干扰判断.将netstat的错误信息重定向以避免干扰.

Close #1
2022-01-16 12:26:30 +08:00
Xu Tianliang
8dea774cee Add missing private subnet 2022-01-03 04:39:51 +08:00
Xu Tianliang
2fdd6b8c39 Fix can't share wifi spot with others on the latest v2ray
Signed-off-by: Xu Tianliang <yorutsuki@live.com>
2022-01-02 03:36:15 +08:00
Xu Tianliang
579ebdc018 Grey out DoT port 853 from proxy
Signed-off-by: Xu Tianliang <yorutsuki@live.com>
2022-01-02 03:32:35 +08:00
12 changed files with 192 additions and 345 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"

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "v2manager"]
path = app
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

1
app Submodule

Submodule app added at 2eda7595de

View File

@@ -7,50 +7,26 @@ 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/etc
# download latest v2ray core from official link
ui_print "- Connect official V2Ray download link."
official_v2ray_link="https://github.com/v2fly/v2ray-core/releases"
latest_v2ray_version=`curl -k -s -I "${official_v2ray_link}/latest" | grep -i location | grep -o "tag.*" | grep -o "v[0-9.]*"`
if [ "${latest_v2ray_version}" = "" ] ; then
ui_print "Error: Connect official V2Ray download link failed."
exit 1
fi
ui_print "- Download latest V2Ray core ${latest_v2ray_version}-${ARCH}"
case "${ARCH}" in
arm)
download_v2ray_link="${official_v2ray_link}/download/${latest_v2ray_version}/v2ray-linux-arm32-v7a.zip"
;;
arm64)
download_v2ray_link="${official_v2ray_link}/download/${latest_v2ray_version}/v2ray-android-arm64-v8a.zip"
;;
x86)
download_v2ray_link="${official_v2ray_link}/download/${latest_v2ray_version}/v2ray-linux-32.zip"
;;
x64)
download_v2ray_link="${official_v2ray_link}/download/${latest_v2ray_version}/v2ray-linux-64.zip"
;;
esac
download_v2ray_zip="/data/v2ray/run/v2ray-core.zip"
curl "${download_v2ray_link}" -k -L -o "${download_v2ray_zip}" >&2
if [ "$?" != "0" ] ; then
ui_print "Error: Download V2Ray core failed."
exit 1
fi
# install v2ray execute file
ui_print "- Install V2Ray core $ARCH execute files"
unzip -j -o "${download_v2ray_zip}" "geoip.dat" -d /data/v2ray >&2
unzip -j -o "${download_v2ray_zip}" "geosite.dat" -d /data/v2ray >&2
unzip -j -o "${download_v2ray_zip}" "v2ray" -d $MODPATH/system/bin >&2
unzip -j -o "${download_v2ray_zip}" "v2ctl" -d $MODPATH/system/bin >&2
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/scripts/*' -d $MODPATH/scripts >&2
unzip -j -o "${ZIPFILE}" "v2ray/bin/$ARCH/dnscrypt-proxy" -d $MODPATH/system/bin >&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
rm "${download_v2ray_zip}"
# copy v2ray data and config
ui_print "- Copy V2Ray config and data files"
@@ -62,17 +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 -n "version=" >> $MODPATH/module.prop
echo ${latest_v2ray_version} >> $MODPATH/module.prop
echo "versionCode=20210801" >> $MODPATH/module.prop
echo "author=chendefine" >> $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"
@@ -80,9 +56,7 @@ set_perm_recursive $MODPATH 0 0 0755 0644
set_perm $MODPATH/service.sh 0 0 0755
set_perm $MODPATH/uninstall.sh 0 0 0755
set_perm $MODPATH/scripts/start.sh 0 0 0755
set_perm $MODPATH/scripts/v2ray.inotify 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 $MODPATH/system/bin/v2ctl ${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=latest_version
versionCode=20210801
author=chendefine
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

@@ -1,155 +1,52 @@
// Config file of V2Ray. This file follows standard JSON format, with comments support.
// Uncomment entries below to satisfy your needs. Also read our manual for more detail at
// https://www.v2ray.com/
{
"log": {
// By default, V2Ray writes access log to stdout.
// "access": "/path/to/access/log/file",
"access": "none",
// By default, V2Ray write error log to stdout.
// "error": "/path/to/error/log/file",
"error": "/data/v2ray/run/error.log",
// Log level, one of "debug", "info", "warning", "error", "none"
"loglevel": "warning"
"loglevel": "warn"
},
// List of inbound proxy configurations.
"inbounds": [{
// Port to listen on. You may need root access if the value is less than 1024.
"port": 65535,
// IP address to listen on. Change to "0.0.0.0" to listen on all network interfaces.
"listen": "0.0.0.0",
// Tag of the inbound proxy. May be used for routing.
"tag": "proxy-inbound",
// Protocol name of inbound proxy.
"protocol": "dokodemo-door",
// Settings of the protocol. Varies based on protocol.
"settings": {
// Disable timeout setting for keeping persistent connection. Such as FCM.
// "timeout": 10,
"network": "tcp,udp",
"followRedirect": true
},
// If you wanna bypass BT streams, you should enable it.
"sniffing": {
"enabled": false
// ,
// "destOverride": ["http", "tls"]
}
"settings": {"network": "tcp", "followRedirect": true},
"sniffing": {"enabled": true, "destOverride": ["http", "tls"]}
}],
// List of outbound proxy configurations.
"outbounds": [{
// Replace your proxy protocol in this section, like: VMESS, VLESS or Shadowsocks
"protocol": "freedom",
// Settings of the protocol. Varies based on protocol.
"settings": {},
// Tag of the outbound. May be used for routing.
"tag": "proxy"
},{
// Protocol name of the outbound proxy.
"protocol": "freedom",
// Settings of the protocol. Varies based on protocol.
"settings": {},
// Tag of the outbound. May be used for routing.
"tag": "direct"
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
// Transport is for global transport settings. If you have multiple transports with same settings
// (say mKCP), you may put it here, instead of in each individual inbound/outbounds.
//"transport": {},
// Routing controls how traffic from inbounds are sent to outbounds.
"routing": {
"domainStrategy": "AsIs",
"rules":[
"dns":{
"hosts": {"dns.google":"8.8.8.8", "dns.alidns.com":"223.5.5.5"},
"servers":[
{
// Bypass private IPs.
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "direct"
"address":"223.5.5.5",
"skipFallback": true,
"domains":["geosite:cn", "geosite:apple-cn", "geosite:google-cn", "geosite:tld-cn", "geosite:category-games@cn"]
},
{
// Bypass all china IPs.
"type": "field",
"ip": ["geoip:cn"],
"outboundTag": "direct"
"address":"https://dns.google/dns-query",
"clientIp": "10.10.10.10", "skipFallback": true,
"domains":["geosite:gfw"]
}
//,
//{
// Bypass all china sites.
// "type": "field",
// "domain": ["geosite:cn"],
// "outboundTag": "direct"
//},
//{
// To bypass all BT streams, you should enable sniffing.
// "type": "field",
// "protocol":["bittorrent"],
// "outboundTag": "direct"
//},
//{
// If your network condition not very well, you could bypass dnscrypt-proxy's upstream DNS.
// "type": "field",
// "domain": [
// "cloudflare-dns.com",
// "doh.opendns.com",
// "dns.google"
// ],
// "outboundTag": "direct"
//},
//{
// Blocks major ads.
// "type": "field",
// "domain": ["geosite:category-ads"],
// "outboundTag": "blocked"
//}
]
},
// Policy controls some internal behavior of how V2Ray handles connections.
// It may be on connection level by user levels in 'levels', or global settings in 'system.'
"policy": {
// Connection policys by user levels
"levels": {
"0": {
"uplinkOnly": 0,
"downlinkOnly": 0
}
"outbounds": [
{
"protocol": "vmess",
"settings": {"vnext":[{"address":"10.10.10.10","port":8080,"users":[{"id":"xxxxxxxx-xxxx","alterId":0, "security": "auto"}]}]},
"tag": "proxy"
},
"system": {
"statsInboundUplink": false,
"statsInboundDownlink": false
}
{"protocol": "freedom","settings": {"domainStrategy": "UseIPv4"},"tag": "direct"},
{"protocol": "blackhole","settings": {},"tag": "blocked"}
],
"routing": {
"domainStrategy": "AsIs",
"domainMatcher":"mph",
"rules":[
{"type": "field","ip": ["geoip:private"],"outboundTag": "direct"}
,{"type": "field","ip": ["223.5.5.5"],"outboundTag": "direct"}
,{"type": "field","domain": ["geosite:cn", "geosite:apple-cn", "geosite:google-cn", "geosite:tld-cn", "geosite:category-games@cn", "geosite:private"],"outboundTag": "direct"}
,{"type": "field","domain": ["geosite:gfw"],"outboundTag": "proxy"}
,{"type": "field","network": "tcp,udp","outboundTag": "direct"}
]
},
// Stats enables internal stats counter.
// This setting can be used together with Policy and Api.
//"stats":{},
// Api enables gRPC APIs for external programs to communicate with V2Ray instance.
//"api": {
//"tag": "api",
//"services": [
// "HandlerService",
// "LoggerService",
// "StatsService"
//]
//},
// You may add other entries to the configuration, but they will not be recognized by V2Ray.
"other": {}
"policy": {}
}

View File

@@ -8,7 +8,16 @@ start_proxy () {
${MODDIR}/v2ray.tproxy enable &>> /data/v2ray/run/service.log &
fi
}
# /system app can not run
# check the app was installed to /data/ at ervery boot
AppIn=`pm list packages -f | grep lintian`
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
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log &
fi
fi

View File

@@ -1,43 +0,0 @@
#!/system/bin/sh
inotify=`realpath $0`
scripts_dir=`dirname ${inotify}`
service="${scripts_dir}/v2ray.service"
tproxy="${scripts_dir}/v2ray.tproxy"
events=$1
monitor_dir=$2
monitor_file=$3
start_v2ray() {
${service} start && \
if [ -f /data/v2ray/appid.list ] || [ -f /data/v2ray/softap.list ] ; then
${tproxy} enable
settings put global airplane_mode_on 1
sleep 1
am broadcast -a android.intent.action.AIRPLANE_MODE
sleep 1
settings put global airplane_mode_on 0
sleep 1
am broadcast -a android.intent.action.AIRPLANE_MODE
fi
}
stop_v2ray() {
${tproxy} disable
${service} stop
}
main() {
if [ ! -f /data/v2ray/manual ] ; then
if [ "${monitor_file}" = "disable" ] ; then
if [ "${events}" = "d" ] ; then
start_v2ray
elif [ "${events}" = "n" ] ; then
stop_v2ray
fi
fi
fi
}
main

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"
@@ -50,7 +50,7 @@ wait_v2ray_listen() {
wait_count=0
v2ray_pid=`cat ${pid_file}`
find_netstat_path && \
check_v2ray_cmd="netstat -tnlp | grep v2ray | grep -q LISTEN" || \
check_v2ray_cmd="netstat -tnlp 2>/dev/null | grep v2ray | grep -q LISTEN" || \
check_v2ray_cmd="ls -lh /proc/${v2ray_pid}/fd | grep -q socket"
while probe_v2ray_alive && ! eval "${check_v2ray_cmd}" && [ ${wait_count} -lt 100 ] ; do
sleep 1 ; wait_count=$((${wait_count} + 1))
@@ -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"
@@ -16,7 +17,7 @@ softap_list=()
v2ray_share=false
proxy_for_app=false
proxy_for_guest=false
intranet=(0.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 224.0.0.0/4 240.0.0.0/4)
intranet=(0.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 224.0.0.0/4 240.0.0.0/4)
suit_iptables_version() {
iptables_version=`iptables -V | grep -o "v1\.[0-9]"`
@@ -46,8 +47,8 @@ find_netstat_path() {
probe_v2ray_listen() {
find_netstat_path || return
v2ray_listen=`netstat -tnlp | grep v2ray | grep LISTEN`
if eval "echo \"${v2ray_listen}\" | grep -q :::${proxy_port}" || eval "echo \"${v2ray_listen}\" | grep -q 0.0.0.0:${proxy_port}" ; then
v2ray_listen=`netstat -tnlp 2>/dev/null | grep v2ray | grep LISTEN`
if eval "echo \"${v2ray_listen}\" | grep -q :::${proxy_port}" || eval "echo \"${v2ray_listen}\" | grep -q 0.0.0.0:${proxy_port}" || eval "echo \"${v2ray_listen}\" | grep -q '\[::\]:${proxy_port}'" ; then
v2ray_share=true
return
elif eval "echo \"${v2ray_listen}\" | grep -q :${proxy_port}" ; then
@@ -120,7 +121,7 @@ flush_nat_iptables() {
echo "[Info]: Clean nat proxy iptables rules."
iptables_chains=`iptables-save -t nat | cut -d ' ' -f 1 | tr "\n" " "`
${iptables_wait} -t nat -D PREROUTING -p tcp -j GUEST_TCP_PROXY 2>/dev/null
${iptables_wait} -t nat -D OUTPUT -p tcp -j APP_TCP_PROXY 2>/dev/null
${iptables_wait} -t nat -D OUTPUT -p tcp ! --dport 853 -j APP_TCP_PROXY 2>/dev/null
if eval "echo \"${iptables_chains}\" | grep -q \":GUEST_TCP_PROXY \"" ; then
${iptables_wait} -t nat -F GUEST_TCP_PROXY
${iptables_wait} -t nat -X GUEST_TCP_PROXY
@@ -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
@@ -176,7 +178,7 @@ proxy_app_tcp_iptables() {
${iptables_wait} -t nat -A APP_TCP_PROXY -m owner ! --uid-owner ${inet_uid} -j V2RAY
fi
## apply proxy rules to iptables
${iptables_wait} -t nat -A OUTPUT -p tcp -j APP_TCP_PROXY
${iptables_wait} -t nat -A OUTPUT -p tcp ! --dport 853 -j APP_TCP_PROXY
}
proxy_guest_tcp_iptables() {