mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-08 23:20:56 +00:00
Add partial matching hint if exact matching found nothing
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
a2951cd3b8
commit
4df7cee6c2
@ -74,7 +74,7 @@ TestAPIAvailability() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
Authentication() {
|
LoginAPI() {
|
||||||
# Try to read the CLI password (if enabled and readable by the current user)
|
# Try to read the CLI password (if enabled and readable by the current user)
|
||||||
if [ -r /etc/pihole/cli_pw ]; then
|
if [ -r /etc/pihole/cli_pw ]; then
|
||||||
password=$(cat /etc/pihole/cli_pw)
|
password=$(cat /etc/pihole/cli_pw)
|
||||||
@ -96,7 +96,7 @@ Authentication() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginAPI() {
|
Authentication() {
|
||||||
sessionResponse="$(curl -skS -X POST "${API_URL}auth" --user-agent "Pi-hole cli " --data "{\"password\":\"${password}\"}" )"
|
sessionResponse="$(curl -skS -X POST "${API_URL}auth" --user-agent "Pi-hole cli " --data "{\"password\":\"${password}\"}" )"
|
||||||
|
|
||||||
if [ -z "${sessionResponse}" ]; then
|
if [ -z "${sessionResponse}" ]; then
|
||||||
|
@ -112,6 +112,12 @@ GenerateOutput() {
|
|||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If no exact results were found, suggest using partial matching
|
||||||
|
if [ "${num_lists}" -eq 0 ] && [ "${num_gravity}" -eq 0 ] && [ "${partial}" = false ]; then
|
||||||
|
printf "%s\n" "Hint: Try partial matching with"
|
||||||
|
printf "%s\n\n" " ${COL_GREEN}pihole -q --partial ${domain}${COL_NC}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
Main() {
|
Main() {
|
||||||
@ -129,12 +135,14 @@ Main() {
|
|||||||
TestAPIAvailability
|
TestAPIAvailability
|
||||||
|
|
||||||
# Authenticate with FTL
|
# Authenticate with FTL
|
||||||
Authentication
|
LoginAPI
|
||||||
|
|
||||||
# send query again
|
# send query again
|
||||||
data=$(GetFTLData "search/${domain}?N=${max_results}&partial=${partial}")
|
data=$(GetFTLData "search/${domain}?N=${max_results}&partial=${partial}")
|
||||||
|
|
||||||
GenerateOutput "${data}"
|
GenerateOutput "${data}"
|
||||||
|
|
||||||
|
# Delete session
|
||||||
LogoutAPI
|
LogoutAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user