mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-27 07:12:27 +00:00
${PIHOLE_DNS_1} is gone, use the first server from pihole-FTL --config dns.upstreams instead
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
19d3489bcb
commit
f16cf71781
1 changed files with 17 additions and 4 deletions
21
gravity.sh
21
gravity.sh
|
@ -538,12 +538,25 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
fi;;
|
fi;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if [[ "${blocked}" == true ]]; then
|
if [[ "${blocked}" == true ]]; then
|
||||||
printf -v ip_addr "%s" "${PIHOLE_DNS_1%#*}"
|
# Get first defined upstream server
|
||||||
if [[ ${PIHOLE_DNS_1} != *"#"* ]]; then
|
local upstream
|
||||||
|
upstream="$(getFTLConfigValue dns.upstreams)"
|
||||||
|
|
||||||
|
# Isolate first upstream server from a string like
|
||||||
|
# [ 1.2.3.4#1234, 5.6.7.8#5678, ... ]
|
||||||
|
upstream="${upstream%%,*}"
|
||||||
|
upstream="${upstream##*[}"
|
||||||
|
upstream="${upstream%%]*}"
|
||||||
|
|
||||||
|
# Get IP address and port of this upstream server
|
||||||
|
local ip_addr port
|
||||||
|
printf -v ip_addr "%s" "${upstream%#*}"
|
||||||
|
if [[ ${upstream} != *"#"* ]]; then
|
||||||
port=53
|
port=53
|
||||||
else
|
else
|
||||||
printf -v port "%s" "${PIHOLE_DNS_1#*#}"
|
printf -v port "%s" "${upstream#*#}"
|
||||||
fi
|
fi
|
||||||
ip=$(dig "@${ip_addr}" -p "${port}" +short "${domain}" | tail -1)
|
ip=$(dig "@${ip_addr}" -p "${port}" +short "${domain}" | tail -1)
|
||||||
if [[ $(echo "${url}" | awk -F '://' '{print $1}') = "https" ]]; then
|
if [[ $(echo "${url}" | awk -F '://' '{print $1}') = "https" ]]; then
|
||||||
|
@ -551,7 +564,7 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
else port=80
|
else port=80
|
||||||
fi
|
fi
|
||||||
bad_list=$(pihole -q -adlist "${domain}" | head -n1 | awk -F 'Match found in ' '{print $2}')
|
bad_list=$(pihole -q -adlist "${domain}" | head -n1 | awk -F 'Match found in ' '{print $2}')
|
||||||
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by ${bad_list%:}. Using DNS on ${PIHOLE_DNS_1} to download ${url}";
|
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by ${bad_list%:}. Using DNS on ${upstream} to download ${url}";
|
||||||
echo -ne " ${INFO} ${str} Pending..."
|
echo -ne " ${INFO} ${str} Pending..."
|
||||||
cmd_ext="--resolve $domain:$port:$ip"
|
cmd_ext="--resolve $domain:$port:$ip"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue