From e9e33a956984a38a78b96385b08cfb8b85ac8b0b Mon Sep 17 00:00:00 2001 From: Whale Choi Date: Thu, 11 Jun 2020 11:26:06 +0800 Subject: [PATCH] [v1.0.12] Only proxy assignation DNS to improve China DNS resolution speed. --- META-INF/com/google/android/update-binary | 20 +++++++++++++------- customize.sh | 2 +- module.prop | 2 +- v2ray/etc/config.json | 1 + v2ray/etc/config.json.template | 1 + v2ray/etc/resolv.conf | 1 - v2ray/scripts/start.sh | 2 +- v2ray/scripts/v2ray-dns.handle | 10 ++++++---- 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 0ec26ba..f28aa9d 100644 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -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 diff --git a/customize.sh b/customize.sh index 8e7bf77..fd678dc 100644 --- a/customize.sh +++ b/customize.sh @@ -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 diff --git a/module.prop b/module.prop index e209b10..8987740 100644 --- a/module.prop +++ b/module.prop @@ -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 diff --git a/v2ray/etc/config.json b/v2ray/etc/config.json index fc0085e..75fcd3b 100644 --- a/v2ray/etc/config.json +++ b/v2ray/etc/config.json @@ -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", diff --git a/v2ray/etc/config.json.template b/v2ray/etc/config.json.template index fc0085e..75fcd3b 100644 --- a/v2ray/etc/config.json.template +++ b/v2ray/etc/config.json.template @@ -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", diff --git a/v2ray/etc/resolv.conf b/v2ray/etc/resolv.conf index 0578d18..bad8aa2 100644 --- a/v2ray/etc/resolv.conf +++ b/v2ray/etc/resolv.conf @@ -1,2 +1 @@ nameserver 114.114.114.114 -nameserver 1.1.1.1 diff --git a/v2ray/scripts/start.sh b/v2ray/scripts/start.sh index 9768b0b..9c44c84 100644 --- a/v2ray/scripts/start.sh +++ b/v2ray/scripts/start.sh @@ -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 & diff --git a/v2ray/scripts/v2ray-dns.handle b/v2ray/scripts/v2ray-dns.handle index 28f47ce..08ba657 100644 --- a/v2ray/scripts/v2ray-dns.handle +++ b/v2ray/scripts/v2ray-dns.handle @@ -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