-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate adblock / tracking block list
Until nextdns.io quota is reached, use script for blocking tracking sites.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |