mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #964 from pi-hole/queryadsonlyexactmatches
pihole -q: Add option to show all partial or only exact matches
This commit is contained in:
commit
bebb569c43
1 changed files with 17 additions and 2 deletions
19
pihole
19
pihole
|
@ -67,14 +67,28 @@ setupLCDFunction() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scanList(){
|
||||||
|
domain="${1}"
|
||||||
|
list="${2}"
|
||||||
|
method="${3}"
|
||||||
|
if [[ ${method} == "-exact" ]] ; then
|
||||||
|
grep -E "(^|\s)${domain}($|\s)" "${list}"
|
||||||
|
else
|
||||||
|
grep "${domain}" "${list}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
queryFunc() {
|
queryFunc() {
|
||||||
domain="${2}"
|
domain="${2}"
|
||||||
|
method="${3}"
|
||||||
lists=( /etc/pihole/list.* /etc/pihole/blacklist.txt)
|
lists=( /etc/pihole/list.* /etc/pihole/blacklist.txt)
|
||||||
for list in ${lists[@]}; do
|
for list in ${lists[@]}; do
|
||||||
count=$(grep -c ${domain} $list)
|
result=$(scanList ${domain} ${list} ${method})
|
||||||
|
# Remove empty lines before couting number of results
|
||||||
|
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||||
echo "::: ${list} (${count} results)"
|
echo "::: ${list} (${count} results)"
|
||||||
if [[ ${count} > 0 ]]; then
|
if [[ ${count} > 0 ]]; then
|
||||||
grep ${domain} ${list}
|
echo "${result}"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
@ -225,6 +239,7 @@ helpFunc() {
|
||||||
::: -h, help Show this help dialog
|
::: -h, help Show this help dialog
|
||||||
::: -v, version Show current versions
|
::: -v, version Show current versions
|
||||||
::: -q, query Query the adlists for a specific domain
|
::: -q, query Query the adlists for a specific domain
|
||||||
|
::: Use pihole -q domain -exact if you want to see exact matches only
|
||||||
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
||||||
::: -a, admin Admin webpage options
|
::: -a, admin Admin webpage options
|
||||||
::: uninstall Uninstall Pi-Hole from your system :(!
|
::: uninstall Uninstall Pi-Hole from your system :(!
|
||||||
|
|
Loading…
Reference in a new issue