There is always the dnsmasq interface:
--conf-script=[ <arg]
Execute , and treat what it emits to stdout as the contents of a configuration file. If the script exits with a non-zero exit code, dnsmasq treats this as a fatal error. The script can be passed arguments, space seperated from the filename and each other so, for instance --conf-dir=/etc/dnsmasq-uncompress-ads /share/ads-domains.gz
with /etc/dnsmasq-uncompress-ads containing
set -e
zcat ${1} | sed -e "s:^:address=/:" -e "s:$:/:"
exit 0
and /share/ads-domains.gz containing a compressed list of ad server domains will save disk space with large ad-server blocklists.
https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
We leverage this here:
See this script gets called on dnsmasq restart and at the moment feeds in the compressed blocklist to dnsmasq on stdout.
This mechanism could be manipulated to actually process and feed in blocklist content. Perhaps conditionally based on the arguments mentioned in the --conf-script description above. So regular dnsmasq restart does something different to dnsmasq restart with special adblock-lean flag(s).
Alternatively, the dnsmasq script could be clever and alter its processing such that if there are intermediate files, then process them into blocklist and feed to dnsmasq in parallel, and otherwise just feed the blocklist file into dnsmasq (on additional restarts independent of adblock-lean).
In any case, we could have the service script generate the intermediate files, then restart dnsmasq to have our special dnsmasq script processes the intermediate files whilst feeding directly into the dnsmasq binary.
That is, our processing is spread across:
- the service script in /etc/init.d/adblock-lean; and
- our custom dnsmasq intiialization script inside /tmp/dnsmasq.d/ or wherever.
See what I mean? Albeit as you can see this gets a little complicated.