mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-29 01:23:18 +00:00
Tweak/gravity dns (#5752)
This commit is contained in:
commit
c911bf30ab
1 changed files with 9 additions and 36 deletions
45
gravity.sh
45
gravity.sh
|
@ -298,49 +298,22 @@ gravity_CheckDNSResolutionAvailable() {
|
||||||
|
|
||||||
# Determine if $lookupDomain is resolvable
|
# Determine if $lookupDomain is resolvable
|
||||||
if timeout 4 getent hosts "${lookupDomain}" &>/dev/null; then
|
if timeout 4 getent hosts "${lookupDomain}" &>/dev/null; then
|
||||||
# Print confirmation of resolvability if it had previously failed
|
echo -e "${OVER} ${TICK} DNS resolution is available\\n"
|
||||||
if [[ -n "${secs:-}" ]]; then
|
|
||||||
echo -e "${OVER} ${TICK} DNS resolution is now available\\n"
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
elif [[ -n "${secs:-}" ]]; then
|
|
||||||
echo -e "${OVER} ${CROSS} DNS resolution is not available"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the /etc/resolv.conf contains resolvers other than 127.0.0.1 then the local dnsmasq will not be queried and pi.hole is NXDOMAIN.
|
|
||||||
# This means that even though name resolution is working, the getent hosts check fails and the holddown timer keeps ticking and eventually fails
|
|
||||||
# So we check the output of the last command and if it failed, attempt to use dig +short as a fallback
|
|
||||||
if timeout 4 dig +short "${lookupDomain}" &>/dev/null; then
|
|
||||||
if [[ -n "${secs:-}" ]]; then
|
|
||||||
echo -e "${OVER} ${TICK} DNS resolution is now available\\n"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
elif [[ -n "${secs:-}" ]]; then
|
|
||||||
echo -e "${OVER} ${CROSS} DNS resolution is not available"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine error output message
|
|
||||||
if pgrep pihole-FTL &>/dev/null; then
|
|
||||||
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} DNS service is not running"
|
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||||
"${PIHOLE_COMMAND}" restartdns
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure DNS server is given time to be resolvable
|
echo -e " ${INFO} Waiting until DNS resolution is available..."
|
||||||
secs="120"
|
until getent hosts github.com &> /dev/null; do
|
||||||
echo -ne " ${INFO} Time until retry: ${secs}"
|
# Append one dot for each second waiting
|
||||||
until timeout 1 getent hosts "${lookupDomain}" &>/dev/null; do
|
str="${str}."
|
||||||
[[ "${secs:-}" -eq 0 ]] && break
|
echo -ne " ${OVER} ${INFO} ${str}"
|
||||||
echo -ne "${OVER} ${INFO} Time until retry: ${secs}"
|
|
||||||
: $((secs--))
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Try again
|
# If we reach this point, DNS resolution is available
|
||||||
gravity_CheckDNSResolutionAvailable
|
echo -e "${OVER} ${TICK} DNS resolution is available"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve blocklist URLs and parse domains from adlist.list
|
# Retrieve blocklist URLs and parse domains from adlist.list
|
||||||
|
|
Loading…
Reference in a new issue