mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-25 07:33:43 +00:00
Merge development into development-v6
This commit is contained in:
commit
200a82acfb
1 changed files with 65 additions and 62 deletions
37
gravity.sh
37
gravity.sh
|
@ -543,19 +543,23 @@ gravity_DownloadBlocklistFromUrl() {
|
|||
# Check if this IP matches any IP of the system
|
||||
if [[ -n "${ip}" && $(grep -Ec "inet(|6) ${ip}" <<<"$(ip a)") -gt 0 ]]; then
|
||||
blocked=true
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
"NXDOMAIN")
|
||||
if [[ $(dig "${domain}" | grep "NXDOMAIN" -c) -ge 1 ]]; then
|
||||
blocked=true
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
"NODATA")
|
||||
if [[ $(dig "${domain}" | grep "NOERROR" -c) -ge 1 ]] && [[ -z $(dig +short "${domain}") ]]; then
|
||||
blocked=true
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
"NULL" | *)
|
||||
if [[ $(dig "${domain}" +short | grep "0.0.0.0" -c) -ge 1 ]]; then
|
||||
blocked=true
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${blocked}" == true ]]; then
|
||||
|
@ -586,7 +590,7 @@ gravity_DownloadBlocklistFromUrl() {
|
|||
else
|
||||
port=80
|
||||
fi
|
||||
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead";
|
||||
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead"
|
||||
echo -ne " ${INFO} ${str} Pending..."
|
||||
cmd_ext="--resolve $domain:$port:$ip"
|
||||
fi
|
||||
|
@ -598,25 +602,21 @@ gravity_DownloadBlocklistFromUrl() {
|
|||
# running the script.
|
||||
if [[ $url == "file://"* ]]; then
|
||||
# Get the file path
|
||||
file_path=$(echo "$url" | cut --delimiter='/' --fields=3-)
|
||||
# Check if the file exists and is a regular file (or a symlink to one)
|
||||
if [[ ! -e $file_path ]]; then
|
||||
file_path=$(echo "$url" | cut -d'/' -f3-)
|
||||
# Check if the file exists and is a regular file (i.e. not a socket, fifo, tty, block). Might still be a symlink.
|
||||
if [[ ! -f $file_path ]]; then
|
||||
# Output that the file does not exist
|
||||
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
||||
download=false
|
||||
elif [[ ! -f $file_path ]]; then
|
||||
# Output that the file is not a regular file
|
||||
echo -e "${OVER} ${CROSS} ${file_path} is not a regular file"
|
||||
download=false
|
||||
else
|
||||
# Check if the file has a+r permissions
|
||||
permissions=$(stat --dereference --format="%a" "$file_path")
|
||||
# Check if the file or a file referenced by the symlink has a+r permissions
|
||||
permissions=$(stat -L -c "%a" "$file_path")
|
||||
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
||||
# Output that we are using the local file
|
||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||
else
|
||||
# Output that the file does not have the correct permissions
|
||||
echo -e "${OVER} ${CROSS} Cannot read file (file needs to have o+r permission)"
|
||||
echo -e "${OVER} ${CROSS} Cannot read file (file needs to have a+r permission)"
|
||||
download=false
|
||||
fi
|
||||
fi
|
||||
|
@ -624,7 +624,7 @@ gravity_DownloadBlocklistFromUrl() {
|
|||
|
||||
if [[ "${download}" == true ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
httpCode=$(curl --connect-timeout ${curl_connect_timeout} --silent --location ${compression} ${cmd_ext} ${heisenbergCompensator} --write-out "%{http_code}" "${url}" --output "${listCurlBuffer}" 2>/dev/null)
|
||||
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" "${url}" -o "${listCurlBuffer}" 2>/dev/null)
|
||||
fi
|
||||
|
||||
case $url in
|
||||
|
@ -900,7 +900,10 @@ for var in "$@"; do
|
|||
case "${var}" in
|
||||
"-f" | "--force") forceDelete=true ;;
|
||||
"-r" | "--repair") repairSelector "$3" ;;
|
||||
"-u" | "--upgrade" ) upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"; exit 0;;
|
||||
"-u" | "--upgrade")
|
||||
upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"
|
||||
exit 0
|
||||
;;
|
||||
"-h" | "--help") helpFunc ;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue