1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 14:58:08 +00:00

Fix pihole status to not rely on a TCP port test. The current test can fail even when there is no error i case the max. number of TCP workers is reached.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2020-07-01 18:39:09 +02:00
parent 56e0549c7a
commit 6009e86947
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

48
pihole
View File

@ -250,16 +250,52 @@ Options:
echo -e "${OVER} ${TICK} ${str}" echo -e "${OVER} ${TICK} ${str}"
} }
analyze_ports() {
# FTL is listening at least on at least one port when this
# function is getting called
if [[ $(grep -c "IPv4" <<< "${1}") -gt 1 ]] && \
[[ $(grep -c "IPv6" <<< "${1}") -gt 1 ]]; then
echo -e " ${TICK} DNS service is listening"
else
echo -e " ${CROSS} DNS service is partially listening"
# Check individual address family/protocol combinations
# For a healthy Pi-hole, they should all be up (nothing printed)
if grep -q "IPv4.*UDP" <<< "${1}"; then
echo -e " ${TICK} UDP (IPv4)"
else
echo -e " ${CROSS} UDP (IPv4)"
fi
if grep -q "IPv4.*TCP" <<< "${1}"; then
echo -e " ${TICK} TCP (IPv4)"
else
echo -e " ${CROSS} TCP (IPv4)"
fi
if grep -q "IPv6.*UDP" <<< "${1}"; then
echo -e " ${TICK} UDP (IPv6)"
else
echo -e " ${CROSS} UDP (IPv6)"
fi
if grep -q "IPv6.*TCP" <<< "${1}"; then
echo -e " ${TICK} TCP (IPv6)"
else
echo -e " ${CROSS} TCP (IPv6)"
fi
echo ""
fi
}
statusFunc() { statusFunc() {
# Determine if service is running on port 53 (Cr: https://superuser.com/a/806331) # Determine if there is a pihole service is listening on port 53
if (echo > /dev/tcp/127.0.0.1/53) >/dev/null 2>&1; then local listening
listening="$(lsof -Pni:53)"
if grep -q "pihole" <<< "${listening}"; then
if [[ "${1}" != "web" ]]; then if [[ "${1}" != "web" ]]; then
echo -e " ${TICK} DNS service is running" analyze_ports "${listening}"
fi fi
else else
case "${1}" in case "${1}" in
"web") echo "-1";; "web") echo "-1";;
*) echo -e " ${CROSS} DNS service is NOT running";; *) echo -e " ${CROSS} DNS service is NOT listening";;
esac esac
return 0 return 0
fi fi
@ -269,13 +305,13 @@ statusFunc() {
# A config is commented out # A config is commented out
case "${1}" in case "${1}" in
"web") echo 0;; "web") echo 0;;
*) echo -e " ${CROSS} Pi-hole blocking is Disabled";; *) echo -e " ${CROSS} Pi-hole blocking is disabled";;
esac esac
elif grep -q "BLOCKING_ENABLED=true" /etc/pihole/setupVars.conf; then elif grep -q "BLOCKING_ENABLED=true" /etc/pihole/setupVars.conf; then
# Configs are set # Configs are set
case "${1}" in case "${1}" in
"web") echo 1;; "web") echo 1;;
*) echo -e " ${TICK} Pi-hole blocking is Enabled";; *) echo -e " ${TICK} Pi-hole blocking is enabled";;
esac esac
else else
# No configs were found # No configs were found