From 4e8bcd67ea9ceb81195a9dfa6b6ddd7474f64565 Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Mon, 25 Nov 2024 08:38:11 +0100 Subject: [PATCH] Improve unbound blocking domains script --- openwrt-unbound-block.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openwrt-unbound-block.sh b/openwrt-unbound-block.sh index e5243d3..ca42148 100755 --- a/openwrt-unbound-block.sh +++ b/openwrt-unbound-block.sh @@ -9,6 +9,10 @@ # AdGuard Tracking Protection filter TMP_FILE=/tmp/adblock + +# Example whitelist: googleadservices.com|test.com|| +ALLOW_DOMAINS='googleadservices.com' + if [ -f $TMP_FILE ]; then rm $TMP_FILE; fi touch $TMP_FILE @@ -19,12 +23,15 @@ curl -SL https://gitlab.com/quidsup/notrack-blocklists/-/raw/master/notrack-malw # EasyPrivacy curl -SL https://easylist.to/easylist/easyprivacy.txt | grep -E '^||' | grep -vE '@|---|!' | sed 's/||//g' >> "$TMP_FILE" +# https://github.com/FiltersHeroes/KADhosts/tree/master +curl -SL https://raw.githubusercontent.com/FiltersHeroes/KADhosts/refs/heads/master/KADhosts.txt | grep '0.0.0.0' | awk '{print $2}' >> "$TMP_FILE" + # Adguard Tracking Protection filter # curl -SL https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_3_Spyware/filter.txt | grep -E '^\|\|' | sed 's/\^.*//g' | sed 's/||//g' | cut -f1 -d'/' | sort | uniq >> "$TMP_FILE" echo "server:" > /etc/unbound/unbound_ext.conf # consider: grep -E '^[a-zA-Z0-9.]' -sort -u "$TMP_FILE" | grep -E '^[a-zA-Z0-9]' | grep -vE '/|!|\^|\(|\)|#|\.$' | grep -vE 'googleadservices.com' | while read -r domain; do +sort -u "$TMP_FILE" | grep -E '^[a-zA-Z0-9]' | grep -vE '/|!|\^|\(|\)|#|\.$' | grep -vE "$ALLOW_DOMAINS" | while read -r domain; do echo -e "\tlocal-zone: \"$domain.\" refuse" >> /etc/unbound/unbound_ext.conf done