Merge pull request #57 from whalechoi/master
[v1.0.12] Only proxy assignation DNS to improve China DNS resolution …
This commit is contained in:
commit
2603c84997
@ -11,7 +11,7 @@ ui_print() { echo "$1"; }
|
|||||||
|
|
||||||
require_new_magisk() {
|
require_new_magisk() {
|
||||||
ui_print "*******************************"
|
ui_print "*******************************"
|
||||||
ui_print " Please install Magisk v19.0+! "
|
ui_print " Please install Magisk v20.0+! "
|
||||||
ui_print "*******************************"
|
ui_print "*******************************"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ mount /data 2>/dev/null
|
|||||||
|
|
||||||
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
|
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
|
||||||
. /data/adb/magisk/util_functions.sh
|
. /data/adb/magisk/util_functions.sh
|
||||||
[ $MAGISK_VER_CODE -lt 19000 ] && require_new_magisk
|
[ $MAGISK_VER_CODE -lt 20000 ] && require_new_magisk
|
||||||
|
|
||||||
if [ $MAGISK_VER_CODE -ge 20400 ]; then
|
if [ $MAGISK_VER_CODE -ge 20400 ]; then
|
||||||
# New Magisk have complete installation logic within util_functions.sh
|
# New Magisk have complete installation logic within util_functions.sh
|
||||||
@ -48,12 +48,15 @@ is_legacy_script() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_modname() {
|
print_modname() {
|
||||||
local len
|
local authlen len namelen pounds
|
||||||
len=`echo -n $MODNAME | wc -c`
|
namelen=`echo -n $MODNAME | wc -c`
|
||||||
|
authlen=$((`echo -n $MODAUTH | wc -c` + 3))
|
||||||
|
[ $namelen -gt $authlen ] && len=$namelen || len=$authlen
|
||||||
len=$((len + 2))
|
len=$((len + 2))
|
||||||
local pounds=`printf "%${len}s" | tr ' ' '*'`
|
pounds=$(printf "%${len}s" | tr ' ' '*')
|
||||||
ui_print "$pounds"
|
ui_print "$pounds"
|
||||||
ui_print " $MODNAME "
|
ui_print " $MODNAME "
|
||||||
|
ui_print " by $MODAUTH "
|
||||||
ui_print "$pounds"
|
ui_print "$pounds"
|
||||||
ui_print "*******************"
|
ui_print "*******************"
|
||||||
ui_print " Powered by Magisk "
|
ui_print " Powered by Magisk "
|
||||||
@ -95,8 +98,9 @@ unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
|
|||||||
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
|
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
|
||||||
MODULEROOT=$NVBASE/$MODDIRNAME
|
MODULEROOT=$NVBASE/$MODDIRNAME
|
||||||
MODID=`grep_prop id $TMPDIR/module.prop`
|
MODID=`grep_prop id $TMPDIR/module.prop`
|
||||||
MODPATH=$MODULEROOT/$MODID
|
|
||||||
MODNAME=`grep_prop name $TMPDIR/module.prop`
|
MODNAME=`grep_prop name $TMPDIR/module.prop`
|
||||||
|
MODAUTH=`grep_prop author $TMPDIR/module.prop`
|
||||||
|
MODPATH=$MODULEROOT/$MODID
|
||||||
|
|
||||||
# Create mod paths
|
# Create mod paths
|
||||||
rm -rf $MODPATH 2>/dev/null
|
rm -rf $MODPATH 2>/dev/null
|
||||||
@ -168,9 +172,11 @@ fi
|
|||||||
# Copy over custom sepolicy rules
|
# Copy over custom sepolicy rules
|
||||||
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
|
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
|
||||||
ui_print "- Installing custom sepolicy patch"
|
ui_print "- Installing custom sepolicy patch"
|
||||||
|
# Remove old recovery logs (which may be filling partition) to make room
|
||||||
|
rm -f $PERSISTDIR/cache/recovery/*
|
||||||
PERSISTMOD=$PERSISTDIR/magisk/$MODID
|
PERSISTMOD=$PERSISTDIR/magisk/$MODID
|
||||||
mkdir -p $PERSISTMOD
|
mkdir -p $PERSISTMOD
|
||||||
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule
|
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule || abort "! Insufficient partition size"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove stuffs that don't belong to modules
|
# Remove stuffs that don't belong to modules
|
||||||
|
@ -69,7 +69,7 @@ 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 -n "version=" >> $MODPATH/module.prop
|
||||||
echo ${latest_v2ray_version} >> $MODPATH/module.prop
|
echo ${latest_v2ray_version} >> $MODPATH/module.prop
|
||||||
echo "versionCode=20200326" >> $MODPATH/module.prop
|
echo "versionCode=20200611" >> $MODPATH/module.prop
|
||||||
echo "author=chendefine" >> $MODPATH/module.prop
|
echo "author=chendefine" >> $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
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
id=v2ray
|
id=v2ray
|
||||||
name=V2ray for Android
|
name=V2ray for Android
|
||||||
version=latest_version
|
version=latest_version
|
||||||
versionCode=20200326
|
versionCode=20200611
|
||||||
author=chendefine
|
author=chendefine
|
||||||
description=V2ray core with service scripts for Android
|
description=V2ray core with service scripts for Android
|
||||||
|
@ -150,6 +150,7 @@
|
|||||||
"domain:shadowsocks.org": "electronicsrealm.com"
|
"domain:shadowsocks.org": "electronicsrealm.com"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
|
// This dns ip address must as same as the DNS proxy in this file at line 30.
|
||||||
"1.1.1.1",
|
"1.1.1.1",
|
||||||
{
|
{
|
||||||
"address": "114.114.114.114",
|
"address": "114.114.114.114",
|
||||||
|
@ -150,6 +150,7 @@
|
|||||||
"domain:shadowsocks.org": "electronicsrealm.com"
|
"domain:shadowsocks.org": "electronicsrealm.com"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
|
// This dns ip address must as same as the DNS proxy in this file at line 30.
|
||||||
"1.1.1.1",
|
"1.1.1.1",
|
||||||
{
|
{
|
||||||
"address": "114.114.114.114",
|
"address": "114.114.114.114",
|
||||||
|
@ -1,2 +1 @@
|
|||||||
nameserver 114.114.114.114
|
nameserver 114.114.114.114
|
||||||
nameserver 1.1.1.1
|
|
||||||
|
@ -11,5 +11,5 @@ start_proxy () {
|
|||||||
}
|
}
|
||||||
if [ ! -f /data/v2ray/manual ] ; then
|
if [ ! -f /data/v2ray/manual ] ; then
|
||||||
start_proxy
|
start_proxy
|
||||||
fi
|
|
||||||
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log &
|
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log &
|
||||||
|
fi
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
host_ip=""
|
host_ip=""
|
||||||
inet_uid="3003"
|
inet_uid="3003"
|
||||||
proxy_port="65534"
|
proxy_port="65534"
|
||||||
|
conf_file="/data/v2ray/config.json"
|
||||||
|
dns_ip=`sed -n '30p' ${conf_file} | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}"`
|
||||||
iptables_wait="iptables"
|
iptables_wait="iptables"
|
||||||
proxy_for_app=false
|
proxy_for_app=false
|
||||||
appid_file="/data/v2ray/appid.list"
|
appid_file="/data/v2ray/appid.list"
|
||||||
@ -111,22 +113,22 @@ proxy_app_dns_iptables() {
|
|||||||
## proxy all apps network
|
## proxy all apps network
|
||||||
if [ "${appid_list[*]}" = "0" ] ; then
|
if [ "${appid_list[*]}" = "0" ] ; then
|
||||||
echo "[Info]: Proxy all APP's DNS request."
|
echo "[Info]: Proxy all APP's DNS request."
|
||||||
${iptables_wait} -t nat -A APP_DNS_PROXY -m owner ! --uid-owner ${inet_uid} -j V2RAY_APP_DNS
|
${iptables_wait} -t nat -A APP_DNS_PROXY -d ${dns_ip}/32 -m owner ! --uid-owner ${inet_uid} -j V2RAY_APP_DNS
|
||||||
## proxy assign app
|
## proxy assign app
|
||||||
else
|
else
|
||||||
for appid in ${appid_list[@]}; do
|
for appid in ${appid_list[@]}; do
|
||||||
probe_uid_app_name ${appid} "Proxy" && \
|
probe_uid_app_name ${appid} "Proxy" && \
|
||||||
${iptables_wait} -t nat -A APP_DNS_PROXY -m owner --uid-owner ${appid} -j V2RAY_APP_DNS
|
${iptables_wait} -t nat -A APP_DNS_PROXY -d ${dns_ip}/32 -m owner --uid-owner ${appid} -j V2RAY_APP_DNS
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
## black-list mode
|
## black-list mode
|
||||||
elif [ "${app_proxy_mode}" = "skip" ] ; then
|
elif [ "${app_proxy_mode}" = "skip" ] ; then
|
||||||
for appid in ${appid_list[@]}; do
|
for appid in ${appid_list[@]}; do
|
||||||
probe_uid_app_name ${appid} "Ignore" && \
|
probe_uid_app_name ${appid} "Ignore" && \
|
||||||
${iptables_wait} -t nat -A APP_DNS_PROXY -m owner --uid-owner ${appid} -j RETURN
|
${iptables_wait} -t nat -A APP_DNS_PROXY -d ${dns_ip}/32 -m owner --uid-owner ${appid} -j RETURN
|
||||||
done
|
done
|
||||||
echo "[Info]: Proxy all remaining APP's DNS request."
|
echo "[Info]: Proxy all remaining APP's DNS request."
|
||||||
${iptables_wait} -t nat -A APP_DNS_PROXY -m owner ! --uid-owner ${inet_uid} -j V2RAY_APP_DNS
|
${iptables_wait} -t nat -A APP_DNS_PROXY -d ${dns_ip}/32 -m owner ! --uid-owner ${inet_uid} -j V2RAY_APP_DNS
|
||||||
fi
|
fi
|
||||||
## apply proxy rules to iptables
|
## apply proxy rules to iptables
|
||||||
${iptables_wait} -t nat -A OUTPUT -p udp --dport 53 -j APP_DNS_PROXY
|
${iptables_wait} -t nat -A OUTPUT -p udp --dport 53 -j APP_DNS_PROXY
|
||||||
|
Loading…
Reference in New Issue
Block a user