mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-05 13:40:56 +00:00
Bug fixes and logging improvements
Finalized for production deployment. Next release targeting a tarball of config files plus additional logging.
This commit is contained in:
parent
b4463bf42c
commit
a9c24b456d
@ -67,8 +67,10 @@ function compareWhitelist {
|
|||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TMP=$(grep -w ".* $line$" "$GRAVITYFILE")
|
TMP=$(grep -w ".* $line$" "$GRAVITYFILE")
|
||||||
echo "$TMP" >> $DEBUG_LOG
|
if [ ! -z "$TMP" ]; then
|
||||||
echo "$TMP" >> $WHITELISTMATCHES
|
echo "$TMP" >> $DEBUG_LOG
|
||||||
|
echo "$TMP" >> $WHITELISTMATCHES
|
||||||
|
fi
|
||||||
done < "$WHITELISTFILE"
|
done < "$WHITELISTFILE"
|
||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
}
|
}
|
||||||
@ -78,34 +80,39 @@ function compareBlacklist {
|
|||||||
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG
|
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG
|
if [ ! -z "$line" ]; then
|
||||||
|
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG
|
||||||
|
fi
|
||||||
done < "$BLACKLISTFILE"
|
done < "$BLACKLISTFILE"
|
||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNslookup {
|
function testNslookup {
|
||||||
TESTURL=""
|
TESTURL="doubleclick.com"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
echo "############ NSLookup Test ############" >> $DEBUG_LOG
|
echo "############ NSLookup Test ############" >> $DEBUG_LOG
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
# Find a blocked url that has not been whitelisted.
|
# Find a blocked url that has not been whitelisted.
|
||||||
while read -r line; do
|
if [ -s "$WHITELISTMATCHES" ]; then
|
||||||
CUTURL=$("$line" | cut -d " " -f2-)
|
while read -r line; do
|
||||||
if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then
|
CUTURL=${line#*" "}
|
||||||
while read -r line2; do
|
if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then
|
||||||
CUTURL2=$("$line2" | cut -d " " -f2-)
|
while read -r line2; do
|
||||||
if [ "$CUTURL" != "$CUTURL2" ]; then
|
CUTURL2=${line2#*" "}
|
||||||
TESTURL="$CUTURL"
|
if [ "$CUTURL" != "$CUTURL2" ]; then
|
||||||
fi
|
TESTURL="$CUTURL"
|
||||||
done < "WHITELISTMATCHES"
|
break 2
|
||||||
fi
|
fi
|
||||||
done < "GRAVITYFILE"
|
done < "$WHITELISTMATCHES"
|
||||||
|
fi
|
||||||
|
done < "$GRAVITYFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG
|
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG
|
||||||
echo nslookup "$TESTURL" >> $DEBUG_LOG
|
nslookup "$TESTURL" >> $DEBUG_LOG
|
||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG
|
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG
|
||||||
echo nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG
|
nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG
|
||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +131,8 @@ echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
|||||||
echo >> $DEBUG_LOG
|
echo >> $DEBUG_LOG
|
||||||
|
|
||||||
# Test the nslookup here
|
# Test the nslookup here
|
||||||
|
compareWhitelist
|
||||||
|
compareBlacklist
|
||||||
testNslookup
|
testNslookup
|
||||||
|
|
||||||
echo "Writing dnsmasq.conf to debug log..."
|
echo "Writing dnsmasq.conf to debug log..."
|
||||||
@ -199,7 +208,6 @@ fi
|
|||||||
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
|
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
|
||||||
echo "Hostname of this pihole is: " >> $DEBUG_LOG
|
echo "Hostname of this pihole is: " >> $DEBUG_LOG
|
||||||
hostname >> $DEBUG_LOG
|
hostname >> $DEBUG_LOG
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
|
|
||||||
echo "Writing hosts file to debug log..."
|
echo "Writing hosts file to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
@ -215,7 +223,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### PiHole application specific logging ###
|
### PiHole application specific logging ###
|
||||||
# Write Pi-Hole logs to debug log
|
|
||||||
echo "Writing whitelist to debug log..."
|
echo "Writing whitelist to debug log..."
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "#######################################" >> $DEBUG_LOG
|
||||||
echo "############## Whitelist ##############" >> $DEBUG_LOG
|
echo "############## Whitelist ##############" >> $DEBUG_LOG
|
||||||
|
Loading…
Reference in New Issue
Block a user