This commit is contained in:
bluemeda 2018-04-17 16:11:52 +07:00
parent 30bc81f703
commit aee00d1821
3 changed files with 82 additions and 2 deletions

74
common/install.sh Normal file
View File

@ -0,0 +1,74 @@
keytest() {
ui_print " - Vol Key Test -"
ui_print " Press Vol Up:"
(/system/bin/getevent -lc 1 2>&1 | /system/bin/grep VOLUME | /system/bin/grep " DOWN" > $INSTALLER/events) || return 1
return 0
}
chooseport() {
#note from chainfire @xda-developers: getevent behaves weird when piped, and busybox grep likes that even less than toolbox/toybox grep
while (true); do
/system/bin/getevent -lc 1 2>&1 | /system/bin/grep VOLUME | /system/bin/grep " DOWN" > $INSTALLER/events
if (`cat $INSTALLER/events 2>/dev/null | /system/bin/grep VOLUME >/dev/null`); then
break
fi
done
if (`cat $INSTALLER/events 2>/dev/null | /system/bin/grep VOLUMEUP >/dev/null`); then
return 0
else
return 1
fi
}
chooseportold() {
# Calling it first time detects previous input. Calling it second time will do what we want
$KEYCHECK
$KEYCHECK
SEL=$?
if [ "$1" == "UP" ]; then
UP=$SEL
elif [ "$1" == "DOWN" ]; then
DOWN=$SEL
elif [ $SEL -eq $UP ]; then
return 0
elif [ $SEL -eq $DOWN ]; then
return 1
else
ui_print " Vol key not detected!"
abort " Use name change method in TWRP"
fi
}
# Keycheck binary by someone755 @Github, idea for code below by Zappo @xda-developers
KEYCHECK=$INSTALLER/common/keycheck
chmod 755 $KEYCHECK
if keytest; then
FUNCTION=chooseport
else
FUNCTION=chooseportold
ui_print " ! Legacy device detected! Using old keycheck method"
ui_print " "
ui_print "- Vol Key Programming -"
ui_print " Press Vol Up Again:"
$FUNCTION "UP"
ui_print " Press Vol Down"
$FUNCTION "DOWN"
fi
ui_print " "
ui_print " Vol+ = Auto redirect DNS request with iptables"
ui_print " "
ui_print " Vol- = Set DNS manually with 3rd-party app"
ui_print " "
if $FUNCTION; then
ui_print " "
ui_print " Auto mode"
else
ui_print " "
ui_print " Manual mode"
ui_print " deleting iptables rules"
sed -i -e '/for/,$d' $INSTALLER/common/service.sh
sed -i -e "s/'127.0.0.1.*'/'127.0.0.1:53', '[::1]:53'/g" $MODPATH/system/etc/dnscrypt-proxy/dnscrypt-proxy.toml
fi

View File

@ -41,7 +41,11 @@ LATESTARTSERVICE=true
print_modname() { print_modname() {
ui_print "*******************************" ui_print "*******************************"
ui_print " Magisk Module Template " ui_print " DNSCrypt-Proxy2 "
ui_print " Magisk Module "
ui_print "*******************************"
ui_print " v2.3.0 "
ui_print " bluemeda "
ui_print "*******************************" ui_print "*******************************"
} }
@ -150,4 +154,6 @@ install_dnscrypt_proxy(){
cp -af $TMPDIR/dnscrypt-proxy.toml $NEW_CONFIG_FILE cp -af $TMPDIR/dnscrypt-proxy.toml $NEW_CONFIG_FILE
fi fi
. $INSTALLER/common/install.sh
} }

View File

@ -1,7 +1,7 @@
id=dnscrypt-proxy id=dnscrypt-proxy
name=DNSCrypt-Proxy 2 name=DNSCrypt-Proxy 2
version=v2.2.0 version=v2.2.0
versionCode=11 versionCode=12
author=bluemeda author=bluemeda
description=A flexible DNS proxy, with support for modern encrypted DNS protocols such as DNSCrypt v2 and DNS-over-HTTP/2. description=A flexible DNS proxy, with support for modern encrypted DNS protocols such as DNSCrypt v2 and DNS-over-HTTP/2.
minMagisk=1500 minMagisk=1500