gaenserich / hostsblock

an ad- and malware-blocking script for Linux
https://github.com/gaenserich/hostsblock
225 stars 28 forks source link

blacklist entries are not always handled correctly #66

Closed Hjdskes closed 7 years ago

Hjdskes commented 7 years ago

Just making sure you see the issue reported here: https://bbs.archlinux.org/viewtopic.php?pid=1702738#p1702738

If I add an entry to my black.list via hostsblock-urlcheck, it will not get added to hosts.block if there is an existing entry with a more restricted domain. For example, if I'm already blocking very.bad.site.com, and I add bad.site.com to the blacklist, it will not show up in hosts.block, and my DNS server (after restart of course) will forward the query and resolve bad.site.com. I can take care of this problem with a tweak in the hostsblock script:

202c202
<         grep -q "$_blacklistline" "$hostsfile" || echo "$redirecturl $_blacklistline" >> "$hostsfile"
---
>         grep -qx "$_blacklistline" "$hostsfile" || echo "$redirecturl $_blacklistline" >> "$hostsfile"

There is a warning in hostsblock.conf, to the effect that additions to the blacklist should be more specific than the most basic domain names, but note that many of the entries coming from the block lists are indeed very stripped-down domains.

gaenserich commented 7 years ago

901ea7e18fbd1d290cfdb6604c14aa5423cf8213

Thanks for the heads up!