rerouting DNS requests reborn

This commit is contained in:
Guillaume Castagnino 2022-05-15 09:50:03 +02:00
parent e9fe79986e
commit 4638288012
Signed by: casta
SSH key fingerprint: SHA256:PtJi7zHrXiSWdLApi+BdpmmbITeLq6cI7LZtgsuAtyk
4 changed files with 25 additions and 6 deletions

View file

@ -3,6 +3,8 @@ __HEADER__
# For OpenCamera to be picked by android 11 camera intend, it must be promoted system application
list_files() {
cat <<EOF
etc/init/reroute-dns.rc
bin/reroute-dns.sh
priv-app/OpenCamera/OpenCamera.apk
EOF
}
@ -123,7 +125,11 @@ case "$1" in
for i in $(list_files); do
f=$(get_output_path "$SYS/$i")
chown root:root $f
chmod 644 $f
if [ "${f##*.}" = "sh" ] ; then
chmod 755 $f
else
chmod 644 $f
fi
chmod 755 $(dirname $f)
done
;;

View file

@ -0,0 +1,2 @@
on boot
exec u:r:su:s0 root root -- /system/bin/reroute-dns.sh

View file

@ -0,0 +1,7 @@
#!/system/bin/sh
export PATH=/system/bin
iptables -t nat -A OUTPUT ! -o tun0 -p udp --dport 53 -j DNAT --to-destination 1.1.1.1
iptables -t nat -A OUTPUT ! -o tun0 -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1

View file

@ -10,11 +10,15 @@ cd "$(dirname $0)"
export PATH="${PATH}:${SYSTEM}/bin:${SYSTEM}/xbin"
# install setup script
echo "Installing setup script"
cp cm-data/system-setup-runonce.sh /sdcard/system-setup-runonce.sh
chown root:root /sdcard/system-setup-runonce.sh
chmod 750 /sdcard/system-setup-runonce.sh
# install iptables script
echo "Installing iptables script"
cp cm-data/reroute-dns.sh ${SYSTEM}/bin/reroute-dns.sh
chown root:root ${SYSTEM}/bin/reroute-dns.sh
chmod 755 ${SYSTEM}/bin/reroute-dns.sh
# install iptables rc
cp cm-data/reroute-dns.rc ${SYSTEM}/etc/init/reroute-dns.rc
chown root:root ${SYSTEM}/etc/init/reroute-dns.rc
chmod 644 ${SYSTEM}/etc/init/reroute-dns.rc
# install restore script
echo "Installing restore script"