From f9d16c2b1525a9dde136be5968583a56723b3a7d Mon Sep 17 00:00:00 2001 From: Pierre Ghiot Date: Sun, 27 Oct 2019 02:07:08 +0200 Subject: [PATCH 1/4] Update webpage.sh Signed-off-by: Mograine --- advanced/Scripts/webpage.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 600a45a5..e990cc22 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -17,6 +17,7 @@ readonly FTLconf="/etc/pihole/pihole-FTL.conf" # 03 -> wildcards readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf" readonly PI_HOLE_BIN_DIR="/usr/local/bin" +readonly dnscustomfile="/etc/pihole/custom.list" coltable="/opt/pihole/COL_TABLE" if [[ -f ${coltable} ]]; then @@ -564,6 +565,17 @@ SetPrivacyLevel() { fi } +AddCustomDNSAddress() { + ip="${args[2]}" + host="${args[3]}" + echo "${ip} ${host}" >> "${dnscustomfile}" +} + +RemoveCustomDNSAddress() { + host="${args[2]}" + sed -i "/.*${host}/d" "${dnscustomfile}" +} + main() { args=("$@") @@ -595,6 +607,8 @@ main() { "audit" ) addAudit "$@";; "clearaudit" ) clearAudit;; "-l" | "privacylevel" ) SetPrivacyLevel;; + "addcustomdns" ) AddCustomDNSAddress;; + "removecustomdns" ) RemoveCustomDNSAddress;; * ) helpFunc;; esac From bb8dbe9da5d703d8a15328ee33c0bda01959e5c4 Mon Sep 17 00:00:00 2001 From: Pierre Ghiot Date: Sun, 27 Oct 2019 02:09:29 +0200 Subject: [PATCH 2/4] Update 01-pihole.conf Signed-off-by: Mograine --- advanced/01-pihole.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf index 38d2c0b5..5919034d 100644 --- a/advanced/01-pihole.conf +++ b/advanced/01-pihole.conf @@ -21,6 +21,7 @@ addn-hosts=/etc/pihole/gravity.list addn-hosts=/etc/pihole/black.list addn-hosts=/etc/pihole/local.list +addn-hosts=/etc/pihole/custom.list domain-needed From 193ff38ab3d6fd49a9912c5e07cd8e098267bf3a Mon Sep 17 00:00:00 2001 From: Mograine Date: Mon, 28 Oct 2019 13:21:05 +0100 Subject: [PATCH 3/4] Allow more precise deletion by passing ip as parameter Signed-off-by: Mograine --- advanced/Scripts/webpage.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index e990cc22..dc2c83af 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -572,8 +572,9 @@ AddCustomDNSAddress() { } RemoveCustomDNSAddress() { - host="${args[2]}" - sed -i "/.*${host}/d" "${dnscustomfile}" + ip="${args[2]}" + host="${args[3]}" + sed -i "/${ip} ${host}/d" "${dnscustomfile}" } main() { From c809c34024ac302e11ba90761526d2c57a006f45 Mon Sep 17 00:00:00 2001 From: Mograine Date: Wed, 27 Nov 2019 00:27:57 +0100 Subject: [PATCH 4/4] Add user feedback Signed-off-by: Mograine --- advanced/Scripts/webpage.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 7568d119..88ee00f8 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -599,15 +599,25 @@ SetPrivacyLevel() { } AddCustomDNSAddress() { + echo -e " ${TICK} Adding custom DNS entry..." + ip="${args[2]}" host="${args[3]}" echo "${ip} ${host}" >> "${dnscustomfile}" + + # Restart dnsmasq to load new custom DNS entries + RestartDNS } RemoveCustomDNSAddress() { + echo -e " ${TICK} Removing custom DNS entry..." + ip="${args[2]}" host="${args[3]}" sed -i "/${ip} ${host}/d" "${dnscustomfile}" + + # Restart dnsmasq to update removed custom DNS entries + RestartDNS } main() {