Adblock-fast: ad-blocking service for dnsmasq, smartdns and unbound

This is a replacement/new version for the simple-adblock package, which couldn't have been taken further while keeping the existing config file structure, hence the new package/name.

Migration script from simple-adblock is included and ran after the installation. It should carry over the lists/domains you've been allowing/blocking with simple-adblock and also stop and disable simple-adblock, so if you're migrating, it should be a smooth and easy process.

This new package auto-detects supported list formats:

  • AdBlockPlus format
  • domains list format
  • hosts file format
  • dnsmasq config file (with both server= and local= statements) format

So pretty much any list which doesn't require the complex processing you can throw at adblock-fast and it should figure it out on the fly.

The README is available at https://docs.openwrt.melmac.net/adblock-fast/.

I'll add more information later, for now I needed the URL to the thread to add to the README. :wink:

10 Likes

Unless anyone has experienced issues with adblock-fast (and the luci app) over the last week of testing, my plan is to merge the update into snapshots and 23.05.0-rc tomorrow.

PS. Many thanks to @jow and @stokito for polishing up the luci app code.

2 Likes

Hi mate could we have a quick breakdown of the difference between addblock and adblock-fast? Pros and cons:

4 Likes

Thanks for releasing this - I like its simplicity. I'm struggling with the "dnsmasq_instance" option, though. I run 3 dnsmasq instances and want to ad-block #0 and #1, so I've set "option dnsmasq_instance '0 1'" in the config file. Running "/etc/init.d/adblock-fast restart" gives "/etc/rc.common: eval: line 606: 1: not found" and the dnsmasq configs don't contain the adblock servers line. Setting it to a single number or '*' works as expected. This is what your doc says about the option:

String of space-separated DNSMASQ instance numbers (or β€˜*’ for all) to be affected by the service.

Works when using list instead of option - you might want to update your doc accordingly.

        list dnsmasq_instance '0'
        list dnsmasq_instance '1'
1 Like

Thanks, I've updated the README, but I suspect an error is coming from the validation on start, so I'll have a look at it at some point.

I tried to use adblock-fast with https://github.com/hagezi/dns-blocklists#multi-normal---all-round-protection- . Using the abp-style list https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/multi.txt it fails to generate the dnsmasq.addnhosts file. Any idea what I am doing wrong?

Tried it with oisd big and it seems to be blocking only when selecting dnsmasq.servers not dnsmasq.addnhosts. Anything I can provide to solve the issue?

With dnsmasq.servers you really need to use a dnsmasq-specific list, or a wildcard-domains list. For dnsmasq.addnhosts, the list of domains has to be non-wildcard, usually.

1 Like

Thanks for the report. That file doesn't have the header the adblock-fast was expecting for the ABP-style list, so I've updated it to better detect ABP-style lists in adblock-fast 1.0.0-3 (available in my repo, instructions are at https://docs.openwrt.melmac.net/). I'd appreciate it if you could test this version before I merge changes to the main OpenWrt packages repository.

Are there lists you're aware of that do use wildcards?

The intention was that adblock-fast should be able to create a dnsmasq.servers file from any combination of formats of input files.

Sorry, I’m referring, for example, to the various oisd formats (see his homepage explanation for deprecating hosts/domains syntax in January).

So if you use a wildcard domain style list as a hosts file, which blocks example.com, it won’t block www.example.com.

Hi Stan, I'm sorry but where do I find the adblock-fast 1.0.0-3 in your repo? Tried to look it up here https://github.com/stangri/repo.openwrt.melmac.net but there's still 1.0.0-2? Or am I looking at the wrong repo?

Thank you in advance

My bad, I've only pushed 1.0.0-3 to my development repo previously, now it's in both. Please refresh/update.

With 1.0.0-3 I was able to use the abp-style list https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/multi.txt as dnsmasq.servers fine.

dnsmasq.addnhosts did not seem to block the ads on my testpages

1 Like

While having a slight performance penalty, dnsmasq.servers is a preferred option.

Thank you for quick testing, PRs with the change have been created:

2 Likes

Quick Feedback: In 1.0.0-4 I no longer get an error message because my allowlist is empty and it works great.

Any idea why I get those messages on restarting dnsmasq:

Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzzhuoxiaqu.online
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzz.fhauiehgha.com
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzz.alie3ksgdd.com
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzyjtsgls.com
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzxmcp.com
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzxedr.xyz
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzux.com
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using only locally-known addresses for zzsqqx.shopjapan.co.jp
Fri Sep 29 22:00:34 2023 daemon.info dnsmasq[1]: using 180808 more local addresses
1 Like

dnsmasq is too chatty and lists the domains from the end of the block-file in the output. It's an indication that dnsmasq picked up the block-list created by the adblock-fast.

Thank you for all the feedback.

I just wanted to try the dnsmasq-style list from hagezi to keep the needed processing low https://raw.githubusercontent.com/hagezi/dns-blocklists/main/dnsmasq/multi.txt but it does not seem to be recognized.

Comparing the generated list from abp-style to the one provided:
dnsmasq-style
address=/0-000.store/#

generated from abp-style
server=/0-000.store/

Also I wanted to add that at least for me blocking over wireguard works without any changes to the configuration.

I'm not sure I fully understand the issue. Can you post your config which is cause the issues and the output of service adblock-fast dl with verbosity set to 2.

Sorry, I'm trying to be better understandable. I tried to use the dnsmasq-style list from the link above (https://raw.githubusercontent.com/hagezi/dns-blocklists/main/dnsmasq/multi.txt) and adblock-fast does not seem to recognize the right format.

Failed to detect format https://raw.githubusercontent.com/hagezi/dns-blocklists/main/dnsmasq/multi.txt
Failed to create '/var/run/adblock-fast/dnsmasq.servers' file
Failed to create block-list or restart DNS resolver```

Edit:
Just forgot to ask. Is there a something like a cron job for updating the blocklists daily?

Edit2:
Upon reloading the service i get this error. Seems to be a cosmetic bug, because I don't have an allow-list.

Service Errors

Failed to process allow-list
Errors encountered, please check the [README](https://docs.openwrt.melmac.net/adblock-fast/)
!```