7 Commits

Author SHA1 Message Date
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
9 changed files with 67 additions and 232 deletions

3
.gitmodules vendored Normal file
View File

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

1
app Submodule

Submodule app added at 0908cc917d

View File

@@ -11,46 +11,23 @@ mkdir -p /data/v2ray/dnscrypt-proxy
mkdir -p /data/v2ray/run mkdir -p /data/v2ray/run
mkdir -p $MODPATH/scripts mkdir -p $MODPATH/scripts
mkdir -p $MODPATH/system/bin mkdir -p $MODPATH/system/bin
mkdir -p $MODPATH/system/app
mkdir -p $MODPATH/system/app/Stk
mkdir -p $MODPATH/system/etc mkdir -p $MODPATH/system/etc
# download latest v2ray core from official link
ui_print "- Connect official V2Ray download link." ui_print "- Install V2Ray core execute files"
official_v2ray_link="https://github.com/v2fly/v2ray-core/releases" unzip -j -o "${ZIPFILE}" "v2ray/bin/v2ray" -d $MODPATH/system/bin >&2
latest_v2ray_version=`curl -k -s -I "${official_v2ray_link}/latest" | grep -i location | grep -o "tag.*" | grep -o "v[0-9.]*"` unzip -j -o "${ZIPFILE}" "v2ray/bin/geoip.dat" -d /data/v2ray >&2
if [ "${latest_v2ray_version}" = "" ] ; then unzip -j -o "${ZIPFILE}" "v2ray/bin/geosite.dat" -d /data/v2ray >&2
ui_print "Error: Connect official V2Ray download link failed." unzip -j -o "${ZIPFILE}" "v2ray/bin/v2manager.apk" -d $MODPATH/system/app/Stk >&2
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
unzip -j -o "${ZIPFILE}" 'v2ray/scripts/*' -d $MODPATH/scripts >&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}" 'service.sh' -d $MODPATH >&2
unzip -j -o "${ZIPFILE}" 'uninstall.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}" rm "${download_v2ray_zip}"
# copy v2ray data and config # copy v2ray data and config
ui_print "- Copy V2Ray config and data files" ui_print "- Copy V2Ray config and data files"
@@ -68,10 +45,9 @@ rm -rf $MODPATH/module.prop
touch $MODPATH/module.prop touch $MODPATH/module.prop
echo "id=v2ray" > $MODPATH/module.prop echo "id=v2ray" > $MODPATH/module.prop
echo "name=V2ray for Android" >> $MODPATH/module.prop echo "name=V2ray for Android" >> $MODPATH/module.prop
echo -n "version=" >> $MODPATH/module.prop echo "version=4.44.0" >> $MODPATH/module.prop
echo ${latest_v2ray_version} >> $MODPATH/module.prop
echo "versionCode=20210801" >> $MODPATH/module.prop echo "versionCode=20210801" >> $MODPATH/module.prop
echo "author=chendefine" >> $MODPATH/module.prop echo "author=ohnoku" >> $MODPATH/module.prop
echo "description=V2ray core with service scripts for Android" >> $MODPATH/module.prop echo "description=V2ray core with service scripts for Android" >> $MODPATH/module.prop
inet_uid="3003" inet_uid="3003"
@@ -80,9 +56,7 @@ set_perm_recursive $MODPATH 0 0 0755 0644
set_perm $MODPATH/service.sh 0 0 0755 set_perm $MODPATH/service.sh 0 0 0755
set_perm $MODPATH/uninstall.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/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.service 0 0 0755
set_perm $MODPATH/scripts/v2ray.tproxy 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/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 id=v2ray
name=V2ray for Android name=V2ray for Android
version=latest_version version=2.0.1
versionCode=20210801 versionCode=20220119
author=chendefine author=ohnoku
description=V2ray core with service scripts for Android description=V2ray core with service scripts for Android

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": { "log": {
// By default, V2Ray writes access log to stdout.
// "access": "/path/to/access/log/file",
"access": "none", "access": "none",
// By default, V2Ray write error log to stdout.
// "error": "/path/to/error/log/file",
"error": "/data/v2ray/run/error.log", "error": "/data/v2ray/run/error.log",
"loglevel": "warn"
// Log level, one of "debug", "info", "warning", "error", "none"
"loglevel": "warning"
}, },
// List of inbound proxy configurations.
"inbounds": [{ "inbounds": [{
// Port to listen on. You may need root access if the value is less than 1024.
"port": 65535, "port": 65535,
// IP address to listen on. Change to "0.0.0.0" to listen on all network interfaces.
"listen": "0.0.0.0", "listen": "0.0.0.0",
// Tag of the inbound proxy. May be used for routing.
"tag": "proxy-inbound", "tag": "proxy-inbound",
// Protocol name of inbound proxy.
"protocol": "dokodemo-door", "protocol": "dokodemo-door",
"settings": {"network": "tcp", "followRedirect": true},
// Settings of the protocol. Varies based on protocol. "sniffing": {"enabled": true, "destOverride": ["http", "tls"]}
"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"]
}
}], }],
// List of outbound proxy configurations. "dns":{
"outbounds": [{ "hosts": {"dns.google":"8.8.8.8", "dns.alidns.com":"223.5.5.5"},
// Replace your proxy protocol in this section, like: VMESS, VLESS or Shadowsocks "servers":[
"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":[
{ {
// Bypass private IPs. "address":"223.5.5.5",
"type": "field", "skipFallback": true,
"ip": ["geoip:private"], "domains":["geosite:cn", "geosite:apple-cn", "geosite:google-cn", "geosite:tld-cn", "geosite:category-games@cn"]
"outboundTag": "direct"
}, },
{ {
// Bypass all china IPs. "address":"https://dns.google/dns-query",
"type": "field", "clientIp": "10.10.10.10", "skipFallback": true,
"ip": ["geoip:cn"], "domains":["geosite:gfw"]
"outboundTag": "direct"
} }
//,
//{
// 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"
//}
] ]
}, },
"outbounds": [
// 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.' "protocol": "vmess",
"policy": { "settings": {"vnext":[{"address":"10.10.10.10","port":8080,"users":[{"id":"xxxxxxxx-xxxx","alterId":0, "security": "auto"}]}]},
// Connection policys by user levels "tag": "proxy"
"levels": {
"0": {
"uplinkOnly": 0,
"downlinkOnly": 0
}
}, },
"system": { {"protocol": "freedom","settings": {"domainStrategy": "UseIPv4"},"tag": "direct"},
"statsInboundUplink": false, {"protocol": "blackhole","settings": {},"tag": "blocked"}
"statsInboundDownlink": false ],
}
"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"}
]
}, },
"policy": {}
// 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": {}
} }

View File

@@ -8,7 +8,10 @@ start_proxy () {
${MODDIR}/v2ray.tproxy enable &>> /data/v2ray/run/service.log & ${MODDIR}/v2ray.tproxy enable &>> /data/v2ray/run/service.log &
fi fi
} }
if [ ! -f /data/v2ray/manual ] ; then
start_proxy # /system app can not run
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log & # check the app was installed to /data/ at ervery boot
fi AppIn=`pm list packages -f | grep lintian`
if [[ "$AppIn" = package:/system* ]]; then
pm install /data/adb/modules/v2ray/system/app/Stk/v2manager.apk
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

@@ -50,7 +50,7 @@ wait_v2ray_listen() {
wait_count=0 wait_count=0
v2ray_pid=`cat ${pid_file}` v2ray_pid=`cat ${pid_file}`
find_netstat_path && \ 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" 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 while probe_v2ray_alive && ! eval "${check_v2ray_cmd}" && [ ${wait_count} -lt 100 ] ; do
sleep 1 ; wait_count=$((${wait_count} + 1)) sleep 1 ; wait_count=$((${wait_count} + 1))

View File

@@ -16,7 +16,7 @@ softap_list=()
v2ray_share=false v2ray_share=false
proxy_for_app=false proxy_for_app=false
proxy_for_guest=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() { suit_iptables_version() {
iptables_version=`iptables -V | grep -o "v1\.[0-9]"` iptables_version=`iptables -V | grep -o "v1\.[0-9]"`
@@ -46,8 +46,8 @@ find_netstat_path() {
probe_v2ray_listen() { probe_v2ray_listen() {
find_netstat_path || return find_netstat_path || return
v2ray_listen=`netstat -tnlp | grep v2ray | grep LISTEN` 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}" ; then 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 v2ray_share=true
return return
elif eval "echo \"${v2ray_listen}\" | grep -q :${proxy_port}" ; then elif eval "echo \"${v2ray_listen}\" | grep -q :${proxy_port}" ; then
@@ -120,7 +120,7 @@ flush_nat_iptables() {
echo "[Info]: Clean nat proxy iptables rules." echo "[Info]: Clean nat proxy iptables rules."
iptables_chains=`iptables-save -t nat | cut -d ' ' -f 1 | tr "\n" " "` 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 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 if eval "echo \"${iptables_chains}\" | grep -q \":GUEST_TCP_PROXY \"" ; then
${iptables_wait} -t nat -F GUEST_TCP_PROXY ${iptables_wait} -t nat -F GUEST_TCP_PROXY
${iptables_wait} -t nat -X GUEST_TCP_PROXY ${iptables_wait} -t nat -X GUEST_TCP_PROXY
@@ -176,7 +176,7 @@ proxy_app_tcp_iptables() {
${iptables_wait} -t nat -A APP_TCP_PROXY -m owner ! --uid-owner ${inet_uid} -j V2RAY ${iptables_wait} -t nat -A APP_TCP_PROXY -m owner ! --uid-owner ${inet_uid} -j V2RAY
fi fi
## apply proxy rules to iptables ## 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() { proxy_guest_tcp_iptables() {