Merge pull request #57 from whalechoi/master

[v1.0.12] Only proxy assignation DNS to improve China DNS resolution …
This commit is contained in:
whyou 2020-06-22 11:18:42 +08:00 committed by GitHub
commit 2603c84997
8 changed files with 24 additions and 15 deletions

View File

@ -11,7 +11,7 @@ ui_print() { echo "$1"; }
require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v19.0+! "
ui_print " Please install Magisk v20.0+! "
ui_print "*******************************"
exit 1
}
@ -27,7 +27,7 @@ mount /data 2>/dev/null
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /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
# New Magisk have complete installation logic within util_functions.sh
@ -48,12 +48,15 @@ is_legacy_script() {
}
print_modname() {
local len
len=`echo -n $MODNAME | wc -c`
local authlen len namelen pounds
namelen=`echo -n $MODNAME | wc -c`
authlen=$((`echo -n $MODAUTH | wc -c` + 3))
[ $namelen -gt $authlen ] && len=$namelen || len=$authlen
len=$((len + 2))
local pounds=`printf "%${len}s" | tr ' ' '*'`
pounds=$(printf "%${len}s" | tr ' ' '*')
ui_print "$pounds"
ui_print " $MODNAME "
ui_print " by $MODAUTH "
ui_print "$pounds"
ui_print "*******************"
ui_print " Powered by Magisk "
@ -95,8 +98,9 @@ unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
MODULEROOT=$NVBASE/$MODDIRNAME
MODID=`grep_prop id $TMPDIR/module.prop`
MODPATH=$MODULEROOT/$MODID
MODNAME=`grep_prop name $TMPDIR/module.prop`
MODAUTH=`grep_prop author $TMPDIR/module.prop`
MODPATH=$MODULEROOT/$MODID
# Create mod paths
rm -rf $MODPATH 2>/dev/null
@ -168,9 +172,11 @@ fi
# Copy over custom sepolicy rules
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
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
mkdir -p $PERSISTMOD
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule || abort "! Insufficient partition size"
fi
# Remove stuffs that don't belong to modules

View File

@ -69,7 +69,7 @@ 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=20200326" >> $MODPATH/module.prop
echo "versionCode=20200611" >> $MODPATH/module.prop
echo "author=chendefine" >> $MODPATH/module.prop
echo "description=V2ray core with service scripts for Android" >> $MODPATH/module.prop

View File

@ -1,6 +1,6 @@
id=v2ray
name=V2ray for Android
version=latest_version
versionCode=20200326
versionCode=20200611
author=chendefine
description=V2ray core with service scripts for Android

View File

@ -150,6 +150,7 @@
"domain:shadowsocks.org": "electronicsrealm.com"
},
"servers": [
// This dns ip address must as same as the DNS proxy in this file at line 30.
"1.1.1.1",
{
"address": "114.114.114.114",

View File

@ -150,6 +150,7 @@
"domain:shadowsocks.org": "electronicsrealm.com"
},
"servers": [
// This dns ip address must as same as the DNS proxy in this file at line 30.
"1.1.1.1",
{
"address": "114.114.114.114",

View File

@ -1,2 +1 @@
nameserver 114.114.114.114
nameserver 1.1.1.1

View File

@ -11,5 +11,5 @@ start_proxy () {
}
if [ ! -f /data/v2ray/manual ] ; then
start_proxy
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log &
fi
inotifyd ${MODDIR}/v2ray.inotify ${MODDIR}/.. &>> /data/v2ray/run/service.log &

View File

@ -3,6 +3,8 @@
host_ip=""
inet_uid="3003"
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"
proxy_for_app=false
appid_file="/data/v2ray/appid.list"
@ -111,22 +113,22 @@ proxy_app_dns_iptables() {
## proxy all apps network
if [ "${appid_list[*]}" = "0" ] ; then
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
else
for appid in ${appid_list[@]}; do
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
fi
## black-list mode
elif [ "${app_proxy_mode}" = "skip" ] ; then
for appid in ${appid_list[@]}; do
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
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
## apply proxy rules to iptables
${iptables_wait} -t nat -A OUTPUT -p udp --dport 53 -j APP_DNS_PROXY