Simple-adblock: fast, lean and fully uci/luci configurable AdBlocking

Since version 1.6 or so, simple-adblock implemented Dirk's (author of adblock) ingenious system of shrinking the dnsmasq file by removing extra entries. For example, if after downloading block lists the block file contains entries like:
advertising.com
www.advertising.com
www1.advertising.com
ads.advertising.com

the last 3 entries can be removed as long as advertising.com stays in the blacklist.

This takes a few extra seconds to process/start but it leads to reduced RAM usage.

1 Like

Hello, I've recently started using your package and I'm loving it, thank you for making it!

There's also something I've noticed: I believe the hotplug script runs for every interface, which makes it start the service a million times after the system starts. I'm new to openwrt, so I can't be sure exactly about what's going on, but I think this is what's happening.

1 Like

If the first start was completed successfully (without download errors), repeated calls of /etc/init.d/simple-adblock start should just display the last ran status.

I've just monitored the logs after a reboot to see exactly what's happening and after the first successful start it prints 'Starting simple-adblock 1.7.0-1...' and restarts dnsmasq for each repeated call. This, combined with a rather big log from the dnsmasq itself on each restart, flooded my logs, which is the reason I started digging in the first place, thinking it was some kind of infinite restart thing.

Of course once it's over, it all works perfectly, but dnsmasq restarts are a little excessive, and it certainly catches attention and can be a little confusing when you look at the logs.

Good catch, it should be fixed in 1.7.0-2 (available in my repo). I would appreciate if you test the hell out of it, so I can send PR for the fix to the official repo.

1 Like

Thank you for the quick fix! Sure, can you please update the source in your repo as well?

Done. (10 chars minimum)

Hi stangri, thanks for releasing more updates. simple-adblock runs great here and will stay with me for a long time! :slight_smile:

Just a question: Would you recommend to use a host based blocklist or a URL based blocklist with simple-adblock? Sure, both are supported. But are there advantages with one method over the other? I have a big blocklist that was released in both formats by the author.

Are whitelisted domain entries in URL format fully compatible with blacklisted Host URL entries?

Edit: Talking about following lists, I'm still deciding if Host based of URL based is better.

Source: https://www.reddit.com/r/pihole/comments/bppug1/introducing_the/

Both are supported because some of the top lists use either/or and not both. :wink:
Given the choice I'd still use domains lists, but difference is negligible, for hosts it's 14 sed rules to filter, for domains it's 11 rules to filter.

PS. recent updates are mostly due to @phasecat's very thorough testing/feedback on fringe cases.

Adding above list to simple-adblock slowed down a lot for me.
Opening websites takes really long now, no matter which site I open.

545124 domains are blocked overall on my Espressobin device, which should be powerful enough for this number of requests.

Is something wrong with the latest version of simple-adblock, which slows down in a specific use case?

Simple-adblock itself just creates the file for dnsmasq and then exits, it doesn't stay running/doesn't slow anything down.

But with half a million records, dnsmasq may slow down. I only have WRT3200, so I have a list of about 40k records (after built-in optimization) and I've increased the dnsmasq cache size to 1000. If you have plenty of RAM, you may want to try an even higher dnsmasq cache size to see if it helps.

I'm not surprised

simple-adblock seems to feed dnsmasq the list similarly as the adblock package does. There's currently a discussion regarding the performance, and why it seems to differ so much from for example pi-hole. The discussion started at this post: Adblock support thread

And a solution was found here: Adblock support thread

Would it be possible to change the working of adblock simply to use addn-hosts to feed dnsmasq the list of domains?

1 Like

Well, I can't optimize the block list if you want to use addnhosts file, but the provisional support for it is enabled in the 1.7.0-17 available from my development repo: ! grep -q 'stangri_dev_repo' /etc/opkg/customfeeds.conf && echo 'src/gz stangri_dev_repo https://dev.melmac.net/openwrt-repo' >> /etc/opkg/customfeeds.conf

You'll need to do

uci set simple-adblock.config.use_addnhosts='1'
uci commit simple-adblock
opkg update
opkg upgrade simple-adblock

There's no support for this option in the luci app yet.

1 Like

This is awesome to hear, thank you! I am definitely gonna play around with this.

What exactly do you mean by this?

1 Like

Thank you very much for your clarification! Those are some pretty neat optimizations! However, having the option to use more RAM to get more performance is definitely a welcome one. But I can also understand that this isn't ideal for everyone. So in my opinion your chosen use_addnhosts is a very elegant solution to give users the power to pick what they prefer :slight_smile:
Thank you very much for this amazing piece of software! Looking forward to seeing this functionality in mainline :slight_smile:

If you end up upgrading to 1.7.1-11 from my dev repo, I've implemented support for dnsmasq config (classic simple-adblock behaviour), dnsmasq additional hosts and dnsmasq servers file. Unbound support is not finished yet. Check the https://github.com/stangri/openwrt_packages/blob/master/simple-adblock/files/README.md#configuration-settings section for details.

If you have an opportunity to run performance/speed tests on all 3 of these options, please do share the results.

I want to switch the default setting from dnsmasq.conf to dnsmasq.servers because it allows for a very quick DNSMASQ reload after initial setup and afaik it's the default behaviour of Dirk's adblock package.

I'd be happy to help. Unfortunately, I am running into an issue trying to install the new version, when running opkg update:

Downloading https://dev.melmac.net/openwrt-repo/Packages.sig
Signature check failed.
Remove wrong Signature file.

Edit:

I am also unsure how to pick between the 3 different DNS resolution options as given on the github page you linked. The github page mentions three different options (actually 4, but you mentioned unbound isn't working yet):

dnsmasq.addnhosts
dnsmasq.conf
dnsmasq.servers

However, in your previous post you mentioned:

So what's the correct way of setting these 3 different modes in the simple-adblock.conf file?

use_addnhosts was deprecated.

Did you add my key?

echo -e -n 'untrusted comment: OpenWrt usign key of Stan Grishin\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /tmp/stangri-repo.pub && opkg-key add /tmp/stangri-repo.pub

Amazing difference, I think the results speak for themselves :slight_smile: From slowest to fastest
The settings that were used was the default configuration file from your development repo. The only thing that was changed was setting enabled to 1, and changing the dns option to the 3 different choices.

dnsmasq server file:

dnsmasq-servers

dnsmasq config file:

dnsmasq-config

dnsmasq addn-host file:

dnsmasq-addnhosts

Edit:

Unfortunately, I am still seeing ads on this page with the addn-hosts option: https://ads-blocker.com/testing/

So we probably are going to need more/larger lists in order to block everything, since as you already mentioned, subdomains aren't blocked. But since the listsize does not affect performance, and only influences the RAM usage, we are free to fill up that RAM to try to improve the blocking :slight_smile: Gonna play around with it some more.

Edit 2:

Hmmm, I uncommented all the lists that were included in the configuration file, but not it's only blocking 20k addresses according to dnsmasq. That was 60k before I uncommented the additional ones. Not sure what's up with that.

Edit 3:

Tried with Pi-holes default lists (110k blocked according to dnsmasq), but I am still seeing the ads on the test page. Could IPv6 have anything to do with it? It shouldn't right? Even if it does the dns request over IPv6, dnsmasq should still return 127.0.0.1 if the name is included in the list, right?

1 Like