Optimization of adblock-lean

BusyBox v1.36.1 (2025-04-14 17:32:05 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 24.10.1, r28597-0425664679
 -----------------------------------------------------
root@rpi4:~# readlink /bin/gzip
busybox

Updated to

Starting adblock-lean, version 513c84f733a18c334b9e1985db041f00cbdc5333.

Seems to update fine now thanks.

I also updated my config file from

blocklist_urls="https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.plus-onlydomains.txt https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif-onlydomains.txt https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/ultimate-onlydomains.txt"

To

blocklist_urls="hagezi:pro.plus hagezi:tif hagezi:ultimate"

Much cleaner.

3 Likes

Great, thank you for testing!

The only issue is that config files using short identifiers won't be backwards compatible with previous adblock-lean versions. But I'm thinking that perhaps this is a good time to leave older versions behind and get rid of some backwards compatibility code. Alternatively, I guess I could implement conversion of short identifiers to URLs when detecting that the user is updating to an older version. What do you think @Lynx?

1 Like

That makes sense. It's not a complicated config to recreate from scratch.

So I changed the update behavior - now it will not allow downgrades to versions prior to v0.7.3. The install script will still allow downrades but will remove the existing config file when downgrading.

I think this should be ready to merge. Should we merge to master and make a new release? @Lynx

1 Like

I think so.

Nice. Should there perhaps be a user prompt or at least warning printed, and ought the previous config to be backed up to prevent the user from inadvertently losing a config?

2 Likes

Done.

v0.7.3 release is up!

3 Likes

I sent a couple of PR's:

@Lynx do you mind reviewing those when you have the time?

1 Like

We've worked through these now. I love how you've taken things so far. Goes to show how with any technical concept there's always room for improvement, even when it seems that none could be left. Recently I hired a Volvo XC90 and it had seats that included ventilation (lots of tiny holes and dedicated fans) - it was terrific and now, having experienced it, I notice its absence. With innovation, there's always something new around the corner!

2 Likes

Time to resurrect this thread again. Following this feature request, I implemented support for adblocking on multiple dnsmasq instances, in this branch. Testing would be nice, even by people who are not using multiple instances, to make sure nothing is broken.

To test:

  1. Remove custom addnmount entries from /etc/config/dhcp (if any)
  2. service adblock-lean update -v branch=support_adblocking_on_multiple_instances (answer n when asked whether you want to start adblock-lean after the update)
  3. service adblock-lean select_dnsmasq_instances
  4. service adblock-lean start

If later you want to go back to current adblock-lean release:

service adblock-lean update -v release
3 Likes

I have a single instance. I followed your instructions, seems to be working fine.

I reverted back to the release version, the process was also seamless. The number of entries in the block file was identical on both versions.

2 Likes

Thank you for testing!

@Lynx do you think we can merge to master and ask for more testing in the main thread?

Yes I think so. I just tested and all seems well at my end too.

I haven't used multiple dnsmasq instances myself yet, but there have been times when I would have had it been supported in OpenWrt back then like it is now.

1 Like

Turns out that I wrote last 3 replies in that thread, so the forum won't allow me to add any more replies until someone else replies :slight_smile: Could you perhaps write this, or just make any reply so it allows me to make the announcement?

This is the text I was trying to post :slight_smile:

Hi all, we're nearing the release of the next adblock-lean version which implements support for adblocking on multiple dnsmasq instances, some other improvements and minor bugfixes. The code has been merged into our 'master' branch and we've done initial testing. Would be nice if more people tested the code before we make a new release. If you want to help with testing:

service adblock-lean update -v snapshot

If you are using multiple dnsmasq instances and would like to adblock on all or some of them, use this command after update:

service adblock-lean select_dnsmasq_instances

If someone here is already using adblock-lean with multiple dnsmasq instances via custom addnmount entries in /etc/config/dhcp, please remove your custom modifications before updating.

If later you want to go back to current adblock-lean release:

service adblock-lean update -v release
1 Like

Let me touch this thread to release you from the block...

3 Likes

This is a cool new feature to have implemented because now users can do things like set up one dnsmasq instance that acts as a child-friendly filter and another that does not have the same.

4 Likes

Hi. I did the update on my R4S and it looks like it ran fine.

( click to expand ) # service adblock-lean update -v snapshot
root@R4S-wrt:~# service adblock-lean update -v snapshot

Downloading adblock-lean, commit '84a458007cb0902e6bc736eeae6d89298d58700a' (update channel: 'snapshot').

Installing new files...
Warning: File '/etc/init.d/adblock-lean' was manually modified - overwriting.
Saved a backup copy of manually modified file to /tmp/abl_old_modified_files/adblock-lean
Copying file '/etc/init.d/adblock-lean'.
Copying file '/usr/lib/adblock-lean/abl-lib.sh'.
Copying file '/usr/lib/adblock-lean/abl-process.sh'.

NOTE: config format has changed from v9 to v10.

Following config options need to be migrated (option name has changed): 'DNSMASQ_INDEX DNSMASQ_CONF_D'.
Corresponding config entries:
DNSMASQ_INDEX="0"
DNSMASQ_CONF_D="/tmp/dnsmasq.cfg01411c.d"

Unexpected keys in config: 'DNSMASQ_INSTANCE'.
Corresponding config entries:
DNSMASQ_INSTANCE="cfg01411c"

Perform following automatic changes? (y|n)
1. Migrate config entries
2. Remove unexpected entries from the config
y|n: y

Old config file was saved as /tmp/adblock-lean_config.old.
This will overwrite existing config. Proceed? (y|n)
y|n: y

Saving new config file to '/etc/adblock-lean/config'.

Checking dnsmasq instances.
adblock-lean has been updated to version '84a458007cb0902e6bc736eeae6d89298d58700a'.

Start adblock-lean now? (y|n)
y|n: y

Starting adblock-lean, version 84a458007cb0902e6bc736eeae6d89298d58700a.

gawk detected so using gawk for fast (sub)domain match removal and entries packing.
GNU sed detected so list processing will be fast.
coreutils-sort detected so sort will be fast.

Checking dnsmasq instances.

Creating uncompressed backup of existing blocklist.

Testing connectivity.

Downloading and processing blocklist parts (max parallel jobs: 4).

Not using any allowlist for blocklist processing.

Starting raw blocklist part(s) download.
Processing raw blocklist: https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro-onlydomains.txt
Processing raw blocklist: https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif-onlydomains.txt
Processing raw blocklist: /etc/adblock-lean/blocklist
Successfully processed list: /etc/adblock-lean/blocklist (16 lines, 432 B).
Successfully processed list: https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro-onlydomains.txt (191,038 lines, 3.43 MiB).
Successfully processed list: https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif-onlydomains.txt (465,310 lines, 7.93 MiB).

Successfully generated preprocessed blocklist file with 656,364 entries.

Sorting and merging the blocklist parts into a single blocklist file.

Stopping dnsmasq.

Checking the resulting blocklist with 'dnsmasq --test'.
New blocklist file check passed.
Final list uncompressed file size: 10.96 MiB.

Importing the blocklist file.

Restarting dnsmasq.

Waiting for dnsmasq initialization.
Restart of dnsmasq completed.

Successfully imported new blocklist file for use by dnsmasq with size: 10.96 MiB.

Processing time for blocklist generation and import: 0m:25s.

Checking the active blocklist.

Checking dnsmasq instances.

Using following nameservers for DNS resolution verification: 127.0.0.1, ::1
Testing adblocking.
Testing DNS resolution.

Active blocklist check passed with the new blocklist.
New blocklist installed with entries count: 568,084.

Checking for adblock-lean updates.
The locally installed adblock-lean is the latest version.
root@R4S-wrt:~# 

I'll run this a few days.

I don't use multiple instances of dnsmasq so I don't have testing feedback for that.

2 Likes

Since we have a confirmation that this works in a setup with multiple dnsmasq instances, I think we can make a new release now? @Lynx

Absolutely. Wow super cool that you can select which out of the existing dnsmasq instances to use.

1 Like