Skip to content

Commit 1d43c0a

Browse files
authored
Merge pull request pi-hole#2693 from pi-hole/release/v4.3
Pi-hole Core v4.3
2 parents b3898b9 + ff5894d commit 1d43c0a

13 files changed

+225
-188
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ The Pi-hole[®](https://pi-hole.net/trademark-rules-and-brand-guidelines/) is a
1717
- **Free**: open source software which helps ensure _you_ are the sole person in control of your privacy
1818

1919
-----
20-
<a href="https://www.codacy.com/app/Pi-hole/pi-hole?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=pi-hole/pi-hole&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/c558a0f8d7124c99b02b84f0f5564238" alt="Codacy Grade"/></a>
21-
<a href="https://travis-ci.org/pi-hole/pi-hole"><img src="https://travis-ci.org/pi-hole/pi-hole.svg?branch=development" alt="Travis Build Status"/></a>
22-
<a href="https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE"><img src="https://www.bountysource.com/badge/tracker?tracker_id=3011939" alt="BountySource"/></a>
20+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c558a0f8d7124c99b02b84f0f5564238)](https://www.codacy.com/app/Pi-hole/pi-hole?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=pi-hole/pi-hole&amp;utm_campaign=Badge_Grade)
21+
[![Build Status](https://travis-ci.org/pi-hole/pi-hole.svg?branch=development)](https://travis-ci.org/pi-hole/pi-hole)
22+
[![BountySource](https://www.bountysource.com/badge/tracker?tracker_id=3011939)](https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE)
2323

2424
## One-Step Automated Install
2525
Those who want to get started quickly and conveniently may install Pi-hole using the following command:
@@ -67,7 +67,7 @@ Sending a donation using our links below is **extremely helpful** in offsetting
6767
If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us:
6868
- [Patreon](https://patreon.com/pihole) _Become a patron for rewards_
6969
- [Digital Ocean](http://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_
70-
- [Stickermule](https://www.stickermule.com/unlock?ref_id=6055890701&utm_medium=link&utm_source=invite) _earn a $10 credit after your first purchase_
70+
- [Stickermule](https://www.stickermule.com/unlock?ref_id=9127301701&utm_medium=link&utm_source=invite) _earn a $10 credit after your first purchase_
7171
- [Pi-hole Swag Store](https://pi-hole.net/shop/) _affiliate link_
7272
- [Amazon](http://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_
7373
- [DNS Made Easy](https://cp.dnsmadeeasy.com/u/133706) _affiliate link_

advanced/Scripts/chronometer.sh

+15-16
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ get_strings() {
444444
}
445445

446446
chronoFunc() {
447+
local extra_arg="$1"
448+
local extra_value="$2"
449+
447450
get_init_stats
448451

449452
for (( ; ; )); do
@@ -461,10 +464,8 @@ chronoFunc() {
461464
fi
462465

463466
# Get refresh number
464-
if [[ "$*" == *"-r"* ]]; then
465-
num="$*"
466-
num="${num/*-r /}"
467-
num="${num/ */}"
467+
if [[ "${extra_arg}" = "refresh" ]]; then
468+
num="${extra_value}"
468469
num_str="Refresh set for every $num seconds"
469470
else
470471
num_str=""
@@ -473,7 +474,7 @@ chronoFunc() {
473474
clear
474475

475476
# Remove exit message heading on third refresh
476-
if [[ "$count" -le 2 ]] && [[ "$*" != *"-e"* ]]; then
477+
if [[ "$count" -le 2 ]] && [[ "${extra_arg}" != "exit" ]]; then
477478
echo -e " ${COL_LIGHT_GREEN}Pi-hole Chronometer${COL_NC}
478479
$num_str
479480
${COL_LIGHT_RED}Press Ctrl-C to exit${COL_NC}
@@ -521,10 +522,10 @@ chronoFunc() {
521522
fi
522523

523524
# Handle exit/refresh options
524-
if [[ "$*" == *"-e"* ]]; then
525+
if [[ "${extra_arg}" == "exit" ]]; then
525526
exit 0
526527
else
527-
if [[ "$*" == *"-r"* ]]; then
528+
if [[ "${extra_arg}" == "refresh" ]]; then
528529
sleep "$num"
529530
else
530531
sleep 5
@@ -561,12 +562,10 @@ if [[ $# = 0 ]]; then
561562
chronoFunc
562563
fi
563564

564-
for var in "$@"; do
565-
case "$var" in
566-
"-j" | "--json" ) jsonFunc;;
567-
"-h" | "--help" ) helpFunc;;
568-
"-r" | "--refresh" ) chronoFunc "$@";;
569-
"-e" | "--exit" ) chronoFunc "$@";;
570-
* ) helpFunc "?";;
571-
esac
572-
done
565+
case "$1" in
566+
"-j" | "--json" ) jsonFunc;;
567+
"-h" | "--help" ) helpFunc;;
568+
"-r" | "--refresh" ) chronoFunc refresh "$2";;
569+
"-e" | "--exit" ) chronoFunc exit;;
570+
* ) helpFunc "?";;
571+
esac

advanced/Scripts/piholeCheckout.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ checkout() {
115115

116116
if [[ "${corebranches[*]}" == *"master"* ]]; then
117117
echo -e "${OVER} ${TICK} $str"
118-
echo -e "${INFO} ${#corebranches[@]} branches available for Pi-hole Core"
118+
echo -e " ${INFO} ${#corebranches[@]} branches available for Pi-hole Core"
119119
else
120120
# Print STDERR output from get_available_branches
121121
echo -e "${OVER} ${CROSS} $str\\n\\n${corebranches[*]}"
@@ -142,7 +142,7 @@ checkout() {
142142

143143
if [[ "${webbranches[*]}" == *"master"* ]]; then
144144
echo -e "${OVER} ${TICK} $str"
145-
echo -e "${INFO} ${#webbranches[@]} branches available for Web Admin"
145+
echo -e " ${INFO} ${#webbranches[@]} branches available for Web Admin"
146146
else
147147
# Print STDERR output from get_available_branches
148148
echo -e "${OVER} ${CROSS} $str\\n\\n${webbranches[*]}"

advanced/Scripts/piholeDebug.sh

+24-17
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ FTL_PORT="${RUN_DIRECTORY}/pihole-FTL.port"
109109
PIHOLE_LOG="${LOG_DIRECTORY}/pihole.log"
110110
PIHOLE_LOG_GZIPS="${LOG_DIRECTORY}/pihole.log.[0-9].*"
111111
PIHOLE_DEBUG_LOG="${LOG_DIRECTORY}/pihole_debug.log"
112-
PIHOLE_DEBUG_LOG_SANITIZED="${LOG_DIRECTORY}/pihole_debug-sanitized.log"
113112
PIHOLE_FTL_LOG="${LOG_DIRECTORY}/pihole-FTL.log"
114113

115114
PIHOLE_WEB_SERVER_ACCESS_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/access.log"
@@ -209,11 +208,6 @@ log_write() {
209208
copy_to_debug_log() {
210209
# Copy the contents of file descriptor 3 into the debug log
211210
cat /proc/$$/fd/3 > "${PIHOLE_DEBUG_LOG}"
212-
# Since we use color codes such as '\e[1;33m', they should be removed before being
213-
# uploaded to our server, since it can't properly display in color
214-
# This is accomplished by use sed to remove characters matching that patter
215-
# The entire file is then copied over to a sanitized version of the log
216-
sed 's/\[[0-9;]\{1,5\}m//g' > "${PIHOLE_DEBUG_LOG_SANITIZED}" <<< cat "${PIHOLE_DEBUG_LOG}"
217211
}
218212

219213
initialize_debug() {
@@ -269,6 +263,9 @@ compare_local_version_to_git_version() {
269263
# The commit they are on
270264
local remote_commit
271265
remote_commit=$(git describe --long --dirty --tags --always)
266+
# Status of the repo
267+
local local_status
268+
local_status=$(git status -s)
272269
# echo this information out to the user in a nice format
273270
# If the current version matches what pihole -v produces, the user is up-to-date
274271
if [[ "${remote_version}" == "$(pihole -v | awk '/${search_term}/ {print $6}' | cut -d ')' -f1)" ]]; then
@@ -291,6 +288,16 @@ compare_local_version_to_git_version() {
291288
fi
292289
# echo the current commit
293290
log_write "${INFO} Commit: ${remote_commit}"
291+
# if `local_status` is non-null, then the repo is not clean, display details here
292+
if [[ ${local_status} ]]; then
293+
#Replace new lines in the status with 12 spaces to make the output cleaner
294+
log_write "${INFO} Status: ${local_status//$'\n'/'\n '}"
295+
local local_diff
296+
local_diff=$(git diff)
297+
if [[ ${local_diff} ]]; then
298+
log_write "${INFO} Diff: ${local_diff//$'\n'/'\n '}"
299+
fi
300+
fi
294301
# If git status failed,
295302
else
296303
# Return an error message
@@ -1134,20 +1141,20 @@ analyze_pihole_log() {
11341141
IFS="$OLD_IFS"
11351142
}
11361143

1137-
tricorder_use_nc_or_ssl() {
1138-
# Users can submit their debug logs using nc (unencrypted) or openssl (enrypted) if available
1139-
# Check for openssl first since encryption is a good thing
1140-
if command -v openssl &> /dev/null; then
1144+
tricorder_use_nc_or_curl() {
1145+
# Users can submit their debug logs using nc (unencrypted) or curl (encrypted) if available
1146+
# Check for curl first since encryption is a good thing
1147+
if command -v curl &> /dev/null; then
11411148
# If the command exists,
1142-
log_write " * Using ${COL_GREEN}openssl${COL_NC} for transmission."
1143-
# encrypt and transmit the log and store the token returned in a variable
1144-
tricorder_token=$(< ${PIHOLE_DEBUG_LOG_SANITIZED} openssl s_client -quiet -connect tricorder.pi-hole.net:${TRICORDER_SSL_PORT_NUMBER} 2> /dev/null)
1149+
log_write " * Using ${COL_GREEN}curl${COL_NC} for transmission."
1150+
# transmit he log via TLS and store the token returned in a variable
1151+
tricorder_token=$(curl --silent --upload-file ${PIHOLE_DEBUG_LOG} https://tricorder.pi-hole.net:${TRICORDER_SSL_PORT_NUMBER})
11451152
# Otherwise,
11461153
else
11471154
# use net cat
11481155
log_write "${INFO} Using ${COL_YELLOW}netcat${COL_NC} for transmission."
11491156
# Save the token returned by our server in a variable
1150-
tricorder_token=$(< ${PIHOLE_DEBUG_LOG_SANITIZED} nc tricorder.pi-hole.net ${TRICORDER_NC_PORT_NUMBER})
1157+
tricorder_token=$(< ${PIHOLE_DEBUG_LOG} nc tricorder.pi-hole.net ${TRICORDER_NC_PORT_NUMBER})
11511158
fi
11521159
}
11531160

@@ -1173,7 +1180,7 @@ upload_to_tricorder() {
11731180
# let the user know
11741181
log_write "${INFO} Debug script running in automated mode"
11751182
# and then decide again which tool to use to submit it
1176-
tricorder_use_nc_or_ssl
1183+
tricorder_use_nc_or_curl
11771184
# If we're not running in automated mode,
11781185
else
11791186
echo ""
@@ -1182,7 +1189,7 @@ upload_to_tricorder() {
11821189
read -r -p "[?] Would you like to upload the log? [y/N] " response
11831190
case ${response} in
11841191
# If they say yes, run our function for uploading the log
1185-
[yY][eE][sS]|[yY]) tricorder_use_nc_or_ssl;;
1192+
[yY][eE][sS]|[yY]) tricorder_use_nc_or_curl;;
11861193
# If they choose no, just exit out of the script
11871194
*) log_write " * Log will ${COL_GREEN}NOT${COL_NC} be uploaded to tricorder.";exit;
11881195
esac
@@ -1209,7 +1216,7 @@ upload_to_tricorder() {
12091216
log_write " * Please try again or contact the Pi-hole team for assistance."
12101217
fi
12111218
# Finally, show where the log file is no matter the outcome of the function so users can look at it
1212-
log_write " * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG_SANITIZED}${COL_NC}\\n"
1219+
log_write " * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG}${COL_NC}\\n"
12131220
}
12141221

12151222
# Run through all the functions we made

advanced/Scripts/query.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ scanList(){
5454
# /dev/null forces filename to be printed when only one list has been generated
5555
# shellcheck disable=SC2086
5656
case "${type}" in
57-
"exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;;
57+
"exact" ) grep -i -E -l "(^|(?<!#)\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;;
5858
"wc" ) grep -i -o -m 1 "/${domain}/" ${lists} 2>/dev/null;;
5959
* ) grep -i "${domain}" ${lists} /dev/null 2>/dev/null;;
6060
esac

advanced/Scripts/update.sh

+14
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ main() {
146146
FTL_update=false
147147
fi
148148

149+
# Determine FTL branch
150+
local ftlBranch
151+
if [[ -f "/etc/pihole/ftlbranch" ]]; then
152+
ftlBranch=$(</etc/pihole/ftlbranch)
153+
else
154+
ftlBranch="master"
155+
fi
156+
157+
if [[ ! "${ftlBranch}" == "master" && ! "${ftlBranch}" == "development" ]]; then
158+
# Notify user that they are on a custom branch which might mean they they are lost
159+
# behind if a branch was merged to development and got abandoned
160+
printf " %b %bWarning:%b You are using FTL from a custom branch (%s) and might be missing future releases.\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}" "${ftlBranch}"
161+
fi
162+
149163
if [[ "${core_update}" == false && "${web_update}" == false && "${FTL_update}" == false ]]; then
150164
echo ""
151165
echo -e " ${TICK} Everything is up to date!"

advanced/Scripts/updatecheck.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function get_local_branch() {
3434
function get_local_version() {
3535
# Return active branch
3636
cd "${1}" 2> /dev/null || return 1
37-
git describe --long --dirty --tags || return 1
37+
git describe --long --dirty --tags 2> /dev/null || return 1
3838
}
3939

4040
# Source the setupvars config file

advanced/Scripts/webpage.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ Interfaces:
530530

531531
Teleporter() {
532532
local datetimestamp=$(date "+%Y-%m-%d_%H-%M-%S")
533-
php /var/www/html/admin/scripts/pi-hole/php/teleporter.php > "pi-hole-teleporter_${datetimestamp}.zip"
533+
php /var/www/html/admin/scripts/pi-hole/php/teleporter.php > "pi-hole-teleporter_${datetimestamp}.tar.gz"
534534
}
535535

536536
addAudit()

advanced/index.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@
4040
// Get extension of current URL
4141
$currentUrlExt = pathinfo($_SERVER["REQUEST_URI"], PATHINFO_EXTENSION);
4242

43-
// Check if this is served over HTTP or HTTPS
44-
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
45-
$proto = "https";
46-
} else {
47-
$proto = "http";
48-
}
49-
5043
// Set mobile friendly viewport
5144
$viewPort = '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>';
5245

@@ -229,10 +222,10 @@ function queryAds($serverName) {
229222
<?=$viewPort ?>
230223
<meta name="robots" content="noindex,nofollow"/>
231224
<meta http-equiv="x-dns-prefetch-control" content="off">
232-
<link rel="shortcut icon" href="<?=$proto ?>://pi.hole/admin/img/favicon.png" type="image/x-icon"/>
233-
<link rel="stylesheet" href="<?=$proto ?>://pi.hole/pihole/blockingpage.css" type="text/css"/>
225+
<link rel="shortcut icon" href="//pi.hole/admin/img/favicon.png" type="image/x-icon"/>
226+
<link rel="stylesheet" href="//pi.hole/pihole/blockingpage.css" type="text/css"/>
234227
<title>● <?=$serverName ?></title>
235-
<script src="<?=$proto ?>://pi.hole/admin/scripts/vendor/jquery.min.js"></script>
228+
<script src="//pi.hole/admin/scripts/vendor/jquery.min.js"></script>
236229
<script>
237230
window.onload = function () {
238231
<?php

0 commit comments

Comments
 (0)