mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Merge pull request #2257 from pi-hole/fix/query-process-wildcards
Move processWildcards to query.sh
This commit is contained in:
commit
6b2851a671
2 changed files with 17 additions and 17 deletions
|
@ -23,6 +23,23 @@ matchType="match"
|
||||||
colfile="/opt/pihole/COL_TABLE"
|
colfile="/opt/pihole/COL_TABLE"
|
||||||
source "${colfile}"
|
source "${colfile}"
|
||||||
|
|
||||||
|
# Print each subdomain
|
||||||
|
# e.g: foo.bar.baz.com = "foo.bar.baz.com bar.baz.com baz.com com"
|
||||||
|
processWildcards() {
|
||||||
|
IFS="." read -r -a array <<< "${1}"
|
||||||
|
for (( i=${#array[@]}-1; i>=0; i-- )); do
|
||||||
|
ar=""
|
||||||
|
for (( j=${#array[@]}-1; j>${#array[@]}-i-2; j-- )); do
|
||||||
|
if [[ $j == $((${#array[@]}-1)) ]]; then
|
||||||
|
ar="${array[$j]}"
|
||||||
|
else
|
||||||
|
ar="${array[$j]}.${ar}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "${ar}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Scan an array of files for matching strings
|
# Scan an array of files for matching strings
|
||||||
scanList(){
|
scanList(){
|
||||||
# Escape full stops
|
# Escape full stops
|
||||||
|
|
17
pihole
17
pihole
|
@ -86,23 +86,6 @@ updateGravityFunc() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print each subdomain
|
|
||||||
# e.g: foo.bar.baz.com = "foo.bar.baz.com bar.baz.com baz.com com"
|
|
||||||
processWildcards() {
|
|
||||||
IFS="." read -r -a array <<< "${1}"
|
|
||||||
for (( i=${#array[@]}-1; i>=0; i-- )); do
|
|
||||||
ar=""
|
|
||||||
for (( j=${#array[@]}-1; j>${#array[@]}-i-2; j-- )); do
|
|
||||||
if [[ $j == $((${#array[@]}-1)) ]]; then
|
|
||||||
ar="${array[$j]}"
|
|
||||||
else
|
|
||||||
ar="${array[$j]}.${ar}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "${ar}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
queryFunc() {
|
queryFunc() {
|
||||||
shift
|
shift
|
||||||
"${PI_HOLE_SCRIPT_DIR}"/query.sh "$@"
|
"${PI_HOLE_SCRIPT_DIR}"/query.sh "$@"
|
||||||
|
|
Loading…
Reference in a new issue