Remove getFTLAPIPort() function and fix pihole status

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König 2023-02-24 21:31:35 +01:00 committed by Adam Warner
parent 44bfb8ebf0
commit b5800ef718
No known key found for this signature in database
4 changed files with 4 additions and 74 deletions

View file

@ -16,7 +16,7 @@ pihole-FTL() {
local ftl_port LINE
# shellcheck disable=SC1091
. /opt/pihole/utils.sh
ftl_port=$(getFTLAPIPort)
ftl_port=$(getFTLConfigValue dns.port)
if [[ -n "$ftl_port" ]]; then
# Open connection to FTL
exec 3<>"/dev/tcp/127.0.0.1/$ftl_port"

View file

@ -81,29 +81,6 @@ removeKey() {
sed -i "/^${key}/d" "${file}"
}
#######################
# returns FTL's current telnet API port based on the setting in /etc/pihole-FTL.conf
########################
getFTLAPIPort(){
local FTLCONFFILE="/etc/pihole/pihole-FTL.conf"
local DEFAULT_FTL_PORT=4711
local ftl_api_port
if [ -s "$FTLCONFFILE" ]; then
# if FTLPORT is not set in pihole-FTL.conf, use the default port
ftl_api_port="$({ grep '^FTLPORT=' "${FTLCONFFILE}" || echo "${DEFAULT_FTL_PORT}"; } | cut -d'=' -f2-)"
# Exploit prevention: set the port to the default port if there is malicious (non-numeric)
# content set in pihole-FTL.conf
expr "${ftl_api_port}" : "[^[:digit:]]" > /dev/null && ftl_api_port="${DEFAULT_FTL_PORT}"
else
# if there is no pihole-FTL.conf, use the default port
ftl_api_port="${DEFAULT_FTL_PORT}"
fi
echo "${ftl_api_port}"
}
#######################
# returns path of FTL's PID file
#######################