From a9927966358dfb05321d3247bc838ec9fd066395 Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Sun, 5 Jan 2025 12:56:30 +0100 Subject: [PATCH] Update 2025-01-05 12:56 OpenBSD/amd64-t14 --- .bin/update-adlist | 63 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/.bin/update-adlist b/.bin/update-adlist index c65d5ba..8d39bdf 100755 --- a/.bin/update-adlist +++ b/.bin/update-adlist @@ -1,11 +1,55 @@ #!/bin/sh -e - trap _restore_all 1 2 3 6 +# list of filenames can can be fetched from $_url _list=/etc/unwind/blocklistproject.txt _url=https://blocklistproject.github.io/Lists/alt-version + +# download blocklists here _dir=/etc/unwind/lists +# combined, sorted and filtered list of all lists configured in $_list +# configure in /etc/unwind.conf: +# block list "/etc/unwind/_assembled.txt" log +_unwind_blocklist="/etc/unwind/_assembled.txt" + +if [ ! -f $_list ] +then + echo "Creating new adlist /etc/unwind/blocklistproject.txt:" + doas mkdir -p $_dir + doas tee $_list < comment + ## # => disabled list (will be deleted if present) + abuse-nl.txt + adobe-nl.txt + ads-nl.txt + basic-nl.txt + crypto-nl.txt + drugs-nl.txt + #everything-nl.txt + facebook-nl.txt + fortnite-nl.txt + fraud-nl.txt + gambling-nl.txt + malware-nl.txt + phishing-nl.txt + piracy-nl.txt + porn-nl.txt + ransomware-nl.txt + redirect-nl.txt + scam-nl.txt + smart-tv-nl.txt + tiktok-nl.txt + torrent-nl.txt + tracking-nl.txt + twitter-nl.txt + vaping-nl.txt + whatsapp-nl.txt + youtube-nl.txt +EOF +fi + _restore_all() { echo "Signal received, aborting..." for _f in $_dir/*.old @@ -53,21 +97,32 @@ _disabled() { return 1 } +_domainfilter() { + # chain grep commands used in assemble pipe + grep -v "torrent" +} + _assemble() { - echo "Assemble blocklist: /etc/unwind/_assembled.txt" + echo "Assemble blocklist: $_unwind_blocklist" cat $_dir/*.txt \ | tr -d " " \ | grep -v '^#' \ | grep -v '^-' \ | grep -v '^$' \ | cut -d "#" -f1 \ - | doas sort -uo /etc/unwind/_assembled.txt + | sed 's/\.$//g' \ + | _domainfilter \ + | doas sort -uo $_unwind_blocklist } + _restart_unwind() { doas rcctl restart unwind } -for _file in $(grep -v "^##" $_list | xargs) + +for _file in $(grep -v "^##" $_list \ + | cut -d "#" -f1 \ + | xargs) do if ! _disabled $_file then