Files
dnscrypt-osxclient/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/switch-to-dnscrypt-if-required.sh
T

45 lines
875 B
Bash
Executable File

#! /bin/ksh
. ./common.inc
PAUSE_MAX=10
PAUSE_INCREMENT=0.1
[ ! -e "$DNSCRYPT_FILE" ] && exit 0
./set-dns-to-dhcp.sh
pause=0
while [ -e "$DNSCRYPT_FILE" ]; do
current_resolvers=$(./get-current-resolvers.sh)
if [ "$current_resolvers" = "$INTERFACE_PROXY" ]; then
if [ ! -e "$PROXY_PID_FILE" ]; then
./start-dnscrypt-proxy.sh || ./switch-to-dhcp.sh
fi
fi
if [ $pause -lt $PAUSE_MAX ]; then
pause=$((pause + $PAUSE_INCREMENT))
fi
sleep $pause
./check-hijacking.sh || continue
./start-dnscrypt-proxy.sh || continue
./check-local-dns.sh || continue
./set-dns.sh "$INTERFACE_PROXY"
if [ $? != 0 ]; then
./set-dns-to-dhcp.sh
continue
fi
./check-hijacking.sh
if [ $? != 0 ]; then
./set-dns-to-dhcp.sh
continue
fi
break
done
if [ ! -e "$DNSCRYPT_FILE" ]; then
touch "$CONTROL_DIR"
fi
exec ./exceptions-add.sh