@ -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 liste ning";;
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 D isabled";;
*) echo -e " ${CROSS} Pi-hole blocking is d isabled";;
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 E nabled";;
*) echo -e " ${TICK} Pi-hole blocking is e nabled";;
esac
esac
else
else
# No configs were found
# No configs were found