Skip to content

Commit

Permalink
Fix PADD -> FTL communication (#149)
Browse files Browse the repository at this point in the history
* Update PADD -> FTL communication as done in pi-hole/pi-hole#3954

* Update version string

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER authored Dec 30, 2020
1 parent 1c93c02 commit 649d67c
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions padd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LC_NUMERIC=C
############################################ VARIABLES #############################################

# VERSION
padd_version="v3.4"
padd_version="v3.5"

# DATE
today=$(date +%Y%m%d)
Expand Down Expand Up @@ -117,34 +117,32 @@ pihole_logo_script_retro_3="${green_text}' ${red_text}' ${magenta_text}' ${ye
############################################# GETTERS ##############################################

GetFTLData() {
# Get FTL port number
ftl_port=$(cat /var/run/pihole-FTL.port)

# Did we find a port for FTL?
if [[ -n "$ftl_port" ]]; then
# Open connection to FTL
exec 3<>"/dev/tcp/localhost/$ftl_port"

# Test if connection is open
if { "true" >&3; } 2> /dev/null; then
# Send command to FTL
echo -e ">$1" >&3

# Read input
read -r -t 1 LINE <&3
until [ ! $? ] || [[ "$LINE" == *"EOM"* ]]; do
echo "$LINE" >&1
read -r -t 1 LINE <&3
done

# Close connection
exec 3>&-
exec 3<&-
local ftl_port LINE
ftl_port=$(cat /run/pihole-FTL.port 2> /dev/null)
if [[ -n "$ftl_port" ]]; then
# Open connection to FTL
exec 3<>"/dev/tcp/127.0.0.1/$ftl_port"

# Test if connection is open
if { "true" >&3; } 2> /dev/null; then
# Send command to FTL and ask to quit when finished
echo -e ">$1 >quit" >&3

# Read input until we received an empty string and the connection is
# closed
read -r -t 1 LINE <&3
until [[ -z "${LINE}" ]] && [[ ! -t 3 ]]; do
echo "$LINE" >&1
read -r -t 1 LINE <&3
done

# Close connection
exec 3>&-
exec 3<&-
fi
else
echo "0"
fi
# We didn't...?
else
echo "0"
fi
}

GetSummaryInformation() {
Expand Down

0 comments on commit 649d67c

Please sign in to comment.