Skip to content

Commit

Permalink
Add script to generate adblock / tracking block list
Browse files Browse the repository at this point in the history
Until nextdns.io quota is reached, use script for blocking
tracking sites.
  • Loading branch information
danpawlik committed Nov 19, 2024
1 parent f3a6bf1 commit d17da1b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions openwrt-unbound-block.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Set custom domain filtering in unbound.
# It is temporary workaround until nextdns request quota is not reset.

# NextDNS rules:
# NoTrack Tracker Blocklist
# EasyPrivacy
# AdGuard Tracking Protection filter

TMP_FILE=/tmp/adblock
if [ -f $TMP_FILE ]; then rm $TMP_FILE; fi
touch $TMP_FILE

# NoTrack Tracker Blocklist
curl -SL https://gitlab.com/quidsup/notrack-blocklists/-/raw/master/notrack-blocklist.txt | sed 's/\#.*//g' | grep -v '^\s*$' >> "$TMP_FILE"
curl -SL https://gitlab.com/quidsup/notrack-blocklists/-/raw/master/notrack-malware.txt | sed 's/\#.*//g' | grep -v '^\s*$' >> "$TMP_FILE"

# EasyPrivacy
curl -SL https://easylist.to/easylist/easyprivacy.txt | grep -E '^||' | grep -vE '@|---|!' | sed 's/||//g' >> "$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 '/|!|\^|\(|\)|#|\.\.' | while read -r domain; do
echo -e "\tlocal-zone: \"$domain.\" refuse" >> /etc/unbound/unbound_ext.conf
done

/etc/init.d/unbound restart

0 comments on commit d17da1b

Please sign in to comment.