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

Thanks for your reply, maybe im doomed to pi-hole then -=x

There are fates far worse I believe :slight_smile:

1 Like

Hello,
I would like it to update the lists automatically, how do i do that? i love your project thank you

As with any repeating job on linux -- use crontab.

/etc/init.d/simple-adblock dl will force-redownload all the lists, /etc/init.d/simple-adblock reload will only redownload all the lists if the previous attempt had any errors.

With FTLDNS under the hood, I believe pi-hole is a superior solution at the moment.

I have been using NextDNS for the past few weeks, and it's been working great as a pihole substitute, in case you haven't checked them out yet.

Hi
How do I allow access for domains
classroom.google.com,
edu.google.com?

Force-reloading simple-adblock 1.8.4-1...
[DL] Config Update: cdn.jsdelivr.net [✓]
[DL] Allowed Domains: classroom.google.com [✗]
[DL] Blocked Domains: s3.amazonaws.com [✓]
[DL] Allowed Domains: classroom.google.com [✗]

Sorting combined list [✓]
Optimizing combined list [✓]
Allowing domains [✓]
Formatting merged file [✓]
Creating DNSMASQ servers file [✓]
Removing temporary files [✓]
Restarting DNSMASQ [✓]
simple-adblock 1.8.4-1 is blocking 18527 domains (with dnsmasq.servers) [✓]
ERROR: failed to parse classroom.google.com!
ERROR: failed to parse https://classroom.google.com!

Thank you.

Simple-adblock did not supported?

I've just successfully installed simple-adblock. Could you please let me know how to check that it is working and blocking whatever it should block :slight_smile:

Check any of the lists you have enabled for blocked domains and try to resolve it from the router or from any LAN client (after reboot, as most computers/phones cache previous DNS replies).

Hi there, I tried running simple-adblock on the latest snapshot (OpenWrt SNAPSHOT r18402-65974aa18b) but dnsmasq is throwing an error:

Mon Dec 27 02:00:53 2021 daemon.err dnsmasq[1]: cannot read /var/run/simple-adblock.servers: No such file or directory

I think the path to the serversfile needs to be added to the dnsmasq jail. Alternatively, the serversfile could be created under dnsmasqconfdir (/tmp/dnsmasq.d) instead.

@discrucio thank you for the report!

I thought any file located there will be attempted to be loaded as dnsmasq config file, however looking at the code the ipset files are stored there already, so can you try running this to fix the simple-adblock code on your router:

sed -i 's|"/var/run/${packageName}.addnhosts"|"/var/dnsmasq.d/${packageName}.addnhosts"|;s|"/var/run/${packageName}.servers"|"/var/dnsmasq.d/${packageName}.servers"|;' /etc/init.d/simple-adblock

Please let me know if it works, so I can merge changes in the repo.

Apologies for the late reply. /var/dnsmasq.d did not work even though /var is symlinked to /tmp :

Summary
Fri Dec 31 14:14:16 2021 daemon.err dnsmasq[1]: cannot read /var/dnsmasq.d/simple-adblock.servers: No such file or directory

Using /tmp/dnsmasq.d worked:

sed -i 's|"/var/run/${packageName}.addnhosts"|"/tmp/dnsmasq.d/${packageName}.addnhosts"|;s|"/var/run/${packageName}.servers"|"/tmp/dnsmasq.d/${packageName}.servers"|;' /etc/init.d/simple-adblock
Summary
Fri Dec 31 14:14:22 2021 daemon.info dnsmasq[1]: using 22873 more local addresses
Fri Dec 31 14:14:23 2021 user.notice simple-adblock [11013]: service is blocking 22874 domains (with dnsmasq.servers) [✓]

Actually, it didn't take me that long, although I'm not sure if it's the most elegant solution: https://github.com/openwrt/openwrt/pull/4908

If you could revert to a simple-adblock IPK from repo and try the /etc/init.d/dnsmasq file from the PR above, I'd appreciate it.

Thanks for the PR! Apologies, this took a while as I had no physical access to the router.

Tested with simple-adblock 1.8.8-1, dnsmasq 2.86-11 on the latest snapshot.

If serversfile is configured in /etc/config/dhcp, but the file does not exist (e.g. when simple-adblock is not started), /etc/init.d/dnsmasq failed to start.

Summary
Wed Feb  9 21:16:10 2022 user.err : jail: creat(/tmp/ujail-DLPBgf/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:10 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:10 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:15 2022 user.err : jail: creat(/tmp/ujail-poGFjh/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:15 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:15 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:20 2022 user.err : jail: creat(/tmp/ujail-CaJMId/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:20 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:20 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:26 2022 user.err : jail: creat(/tmp/ujail-oAcDPn/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:26 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:26 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:31 2022 user.err : jail: creat(/tmp/ujail-begecc/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:31 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:31 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:36 2022 user.err : jail: creat(/tmp/ujail-MNeMCA/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:16:36 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:16:36 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:16:36 2022 daemon.info procd: Instance dnsmasq::cfg01411c s in a crash loop 6 crashes, 0 seconds since last crash

To fix this, I changed the test to -e in this line.

I also tested placing serversfile in /tmp but it causes an additional error message (I noticed that serversfile_dir is evaluated as /var instead of /tmp).

Summary
Wed Feb  9 21:49:54 2022 user.notice dnsmasq: DNS rebinding protection is active, will discard upstream RFC1918 responses!
Wed Feb  9 21:49:54 2022 user.notice dnsmasq: Allowing 127.0.0.0/8 responses
Wed Feb  9 21:49:57 2022 user.err : jail: creat(/tmp/ujail-DlLKGa/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:49:57 2022 user.err : jail: creat(/tmp/ujail-DlLKGa/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:49:57 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:49:57 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:02 2022 user.err : jail: creat(/tmp/ujail-JamKnb/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:50:02 2022 user.err : jail: creat(/tmp/ujail-JamKnb/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:50:02 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:50:02 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:07 2022 user.err : jail: creat(/tmp/ujail-JObPeo/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:50:07 2022 user.err : jail: creat(/tmp/ujail-JObPeo/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:50:07 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:50:07 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:12 2022 user.err : jail: creat(/tmp/ujail-IgeJGl/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:50:12 2022 user.err : jail: creat(/tmp/ujail-IgeJGl/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:50:12 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:50:12 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:17 2022 user.err : jail: creat(/tmp/ujail-dEigPN/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:50:17 2022 user.err : jail: creat(/tmp/ujail-dEigPN/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:50:17 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:50:17 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:22 2022 user.err : jail: creat(/tmp/ujail-EkLlfM/var/etc/dnsmasq.conf.cfg01411c) failed: Read-only file system
Wed Feb  9 21:50:22 2022 user.err : jail: creat(/tmp/ujail-EkLlfM/var/run/ubus/ubus.sock) failed: No such device or address
Wed Feb  9 21:50:22 2022 user.err : jail: mount_all() failed
Wed Feb  9 21:50:22 2022 user.err : jail: failed to build jail fs
Wed Feb  9 21:50:22 2022 daemon.info procd: Instance dnsmasq.err::cfg01411c s in a crash loop 6 crashes, 0 seconds since last crash

Since some devices could have a persistent /var, perhaps both paths should be checked?

I don't understand how simple-adblock is heavier than adblock. Actually yes and it is because of OpenSSL.

Do you want to send PR against dnsmasq init file for this? Does dnsmasq start if the file exists but is zero? You may want to switch -e to -s depending if it does or doesn't.

You mean in the dnsmasq init file? Maybe you should start a separate thread about it.

Actually simple-adblock has no direct dependencies on OpenSSL. It does need an https-capable downloader between uclient-fetch, wget or curl and AFAIK they all have falvours depending on your preferred SSL library (a very compact WolfSSL by default).

I have downloaded curl and it still asks for OpenSSL.

Unless you (or whoever created your image) specifically selected OpenSSL in the make options for the curl/libcurl/image, in OpenWrt 21.02.1 and later curl depends on libwolfssl:

SG-135 in ~ # opkg info libcurl4
Package: libcurl4
Version: 7.81.0-0
Depends: libc, libwolfssl4.8.1.66253b90, libnghttp2-14, ca-bundle
Provides: libcurl
Status: install user installed
Section: libs
Architecture: x86_64
Size: 159900
Filename: x86_64/libcurl4_7.81.0-0_x86_64.ipk
Description: A client-side URL transfer library
Installed-Time: 1641757976