Last active
January 22, 2017 18:02
-
-
Save sorz/6710de8e728331dbd72e2052edd0ddec to your computer and use it in GitHub Desktop.
Adblock list & domain-only list to dnsmasq's configuration. (NXDOMAIN returned by dnsmasq instead of 127.0.0.1 or sort of thing on hosts-file-based solution.)
This file contains hidden or 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
#!/usr/bin/env python3 | |
import re | |
import sys | |
RE_HOST = r'^\|\|([a-z0-9\.\-]+[a-z]+[a-z0-9\.\-]+)\^$' | |
def main(): | |
re_host = re.compile(RE_HOST) | |
for line in sys.stdin: | |
line = line.strip() | |
match = re_host.match(line) | |
if match: | |
host = match[1] | |
print(f'address=/{host}/') | |
if __name__ == '__main__': | |
main() | |
This file contains hidden or 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
[Unit] | |
Description=Update dnsmasq's blacklisted domains. | |
[Service] | |
Type=simple | |
User=dnsmasq | |
WorkingDirectory=/opt/dnsmasq-blacklist | |
ExecStartPre=/usr/bin/curl --head google.com -o /dev/null | |
ExecStart=/opt/dnsmasq-blacklist/update-list.sh | |
ExecStopPost=+/usr/bin/systemctl restart dnsmasq.service |
This file contains hidden or 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
[Unit] | |
Description=Update dnsmasq's blacklisted domains. | |
[Timer] | |
OnCalendar=weekly | |
RandomizedDelaySec=12h | |
AccuracySec=1h | |
Persistent=True | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or 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
https://easylist-downloads.adblockplus.org/easylist.txt | |
https://easylist-downloads.adblockplus.org/easyprivacy.txt | |
https://easylist-downloads.adblockplus.org/easylistchina.txt | |
https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt | |
https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt |
This file contains hidden or 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
https://mirror1.malwaredomains.com/files/justdomains | |
https://pgl.yoyo.org/adservers/serverlist.php?mimetype=plaintext |
This file contains hidden or 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
#!/bin/bash | |
DEST=/etc/dnsmasq.d/blackdomain.conf | |
printf "# Generated at `date`\n" > $DEST | |
while read list; do | |
printf "\n# $list\n" >> $DEST | |
curl $list | while read domain; do | |
printf "address=/$domain/\n" >> $DEST | |
done | |
done < list-domain.txt | |
while read list; do | |
printf "\n# $list\n" >> $DEST | |
curl $list | ./adb2dnsmasq.py >> $DEST | |
done < list-adb.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment