Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDL6ER <dl6er@dl6er.de>2019-08-10 14:33:30 +0300
committerDL6ER <dl6er@dl6er.de>2019-08-10 14:33:30 +0300
commit741c19b9759c16cf3dbfb97482adc2c8e77d1e14 (patch)
tree11c580c6364d25da78bf2592e438dbc096369d89
parent3420439f31f7e27b234844498dbd52329b15526f (diff)
Use compression (if available) when downloading the ad lists.v4.3.4int
Signed-off-by: DL6ER <dl6er@dl6er.de>
-rwxr-xr-xgravity.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/gravity.sh b/gravity.sh
index d7c66d68..fbfdd2c4 100755
--- a/gravity.sh
+++ b/gravity.sh
@@ -311,7 +311,7 @@ gravity_SetDownloadOptions() {
# Download specified URL and perform checks on HTTP status and file content
gravity_DownloadBlocklistFromUrl() {
- local url="${1}" cmd_ext="${2}" agent="${3}" heisenbergCompensator="" patternBuffer str httpCode success=""
+ local url="${1}" cmd_ext="${2}" agent="${3}" heisenbergCompensator="" patternBuffer str httpCode success="" compression
# Create temp file to store content on disk instead of RAM
patternBuffer=$(mktemp -p "/tmp" --suffix=".phgpb")
@@ -359,8 +359,18 @@ gravity_DownloadBlocklistFromUrl() {
echo -ne " ${INFO} ${str} Pending..."
cmd_ext="--resolve $domain:$port:$ip $cmd_ext"
fi
+
+ # Use compression to reduce the amount of data that is transfered
+ # between the Pi-hole and the ad list provider. Use this feature
+ # only if it is supported by the locally available version of curl
+ if curl -V | grep -q "Features:.* libz"; then
+ compression="--compressed"
+ else
+ compression=""
+ fi
+
# 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 ${compression} ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" -A "${agent}" "${url}" -o "${patternBuffer}" 2> /dev/null)
case $url in
# Did we "download" a local file?