mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Allow to add local lists to gravity using e.g. file:///path/to/my.list in adlists.list
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
1556163fb0
commit
164a81776e
1 changed files with 26 additions and 18 deletions
44
gravity.sh
44
gravity.sh
|
@ -138,8 +138,9 @@ gravity_Collapse() {
|
||||||
# Logic: Split by folder/port
|
# Logic: Split by folder/port
|
||||||
awk -F '[/:]' '{
|
awk -F '[/:]' '{
|
||||||
# Remove URL protocol & optional username:password@
|
# Remove URL protocol & optional username:password@
|
||||||
gsub(/(.*:\/\/|.*:.*@)/, "", $0)
|
gsub(/(.*:\/\/|)/, "", $0)
|
||||||
print $1
|
if(length($1)>0){print $1}
|
||||||
|
else {print "local"}
|
||||||
}' <<< "$(printf '%s\n' "${sources[@]}")" 2> /dev/null
|
}' <<< "$(printf '%s\n' "${sources[@]}")" 2> /dev/null
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
@ -203,20 +204,27 @@ gravity_Pull() {
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
httpCode=$(curl -s -L ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" -A "${agent}" "${url}" -o "${patternBuffer}" 2> /dev/null)
|
httpCode=$(curl -s -L ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" -A "${agent}" "${url}" -o "${patternBuffer}" 2> /dev/null)
|
||||||
|
|
||||||
# Determine "Status:" output based on HTTP response
|
case $url in
|
||||||
case "${httpCode}" in
|
# Did we "download" a remote file?
|
||||||
"200") echo -e "${OVER} ${TICK} ${str} Retrieval successful"; success=true;;
|
"http"*)
|
||||||
"304") echo -e "${OVER} ${TICK} ${str} No changes detected"; success=true;;
|
# Determine "Status:" output based on HTTP response
|
||||||
"000") echo -e "${OVER} ${CROSS} ${str} Connection Refused";;
|
case "${httpCode}" in
|
||||||
"403") echo -e "${OVER} ${CROSS} ${str} Forbidden";;
|
"200") echo -e "${OVER} ${TICK} ${str} Retrieval successful"; success=true;;
|
||||||
"404") echo -e "${OVER} ${CROSS} ${str} Not found";;
|
"304") echo -e "${OVER} ${TICK} ${str} No changes detected"; success=true;;
|
||||||
"408") echo -e "${OVER} ${CROSS} ${str} Time-out";;
|
"000") echo -e "${OVER} ${CROSS} ${str} Connection Refused";;
|
||||||
"451") echo -e "${OVER} ${CROSS} ${str} Unavailable For Legal Reasons";;
|
"403") echo -e "${OVER} ${CROSS} ${str} Forbidden";;
|
||||||
"500") echo -e "${OVER} ${CROSS} ${str} Internal Server Error";;
|
"404") echo -e "${OVER} ${CROSS} ${str} Not found";;
|
||||||
"504") echo -e "${OVER} ${CROSS} ${str} Connection Timed Out (Gateway)";;
|
"408") echo -e "${OVER} ${CROSS} ${str} Time-out";;
|
||||||
"521") echo -e "${OVER} ${CROSS} ${str} Web Server Is Down (Cloudflare)";;
|
"451") echo -e "${OVER} ${CROSS} ${str} Unavailable For Legal Reasons";;
|
||||||
"522") echo -e "${OVER} ${CROSS} ${str} Connection Timed Out (Cloudflare)";;
|
"500") echo -e "${OVER} ${CROSS} ${str} Internal Server Error";;
|
||||||
* ) echo -e "${OVER} ${CROSS} ${str} ${httpCode}";;
|
"504") echo -e "${OVER} ${CROSS} ${str} Connection Timed Out (Gateway)";;
|
||||||
|
"521") echo -e "${OVER} ${CROSS} ${str} Web Server Is Down (Cloudflare)";;
|
||||||
|
"522") echo -e "${OVER} ${CROSS} ${str} Connection Timed Out (Cloudflare)";;
|
||||||
|
* ) echo -e "${OVER} ${CROSS} ${str} ${httpCode}";;
|
||||||
|
esac;;
|
||||||
|
# Did we "download" a local file?
|
||||||
|
"file"*) echo -e "${OVER} ${TICK} ${str} Retrieval successful"; success=true;;
|
||||||
|
* ) echo -e "${OVER} ${CROSS} ${str} ${url} ${httpCode}";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Determine if the blocklist was downloaded and saved correctly
|
# Determine if the blocklist was downloaded and saved correctly
|
||||||
|
@ -229,7 +237,7 @@ gravity_Pull() {
|
||||||
gravity_ParseFileIntoDomains "${patternBuffer}" "${saveLocation}"
|
gravity_ParseFileIntoDomains "${patternBuffer}" "${saveLocation}"
|
||||||
else
|
else
|
||||||
# Fall back to previously cached list if $patternBuffer is empty
|
# Fall back to previously cached list if $patternBuffer is empty
|
||||||
echo -e " ${INFO} Received empty file: ${COL_LIGHT_GREEN}using previously cached list${COL_NC}"
|
echo -e " ${INFO} ${COL_LIGHT_GREEN}Using previously cached list${COL_NC}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Determine if cached list has read permission
|
# Determine if cached list has read permission
|
||||||
|
@ -407,7 +415,7 @@ gravity_Filter() {
|
||||||
|
|
||||||
# Whitelist unique blocklist domain sources
|
# Whitelist unique blocklist domain sources
|
||||||
gravity_WhitelistBLD() {
|
gravity_WhitelistBLD() {
|
||||||
local uniqDomains plural="" str
|
local uniqDomains plural="" str
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue