adblock: update 4.1.5-10
authorDirk Brenken <dev@brenken.org>
Thu, 27 Jun 2024 05:47:10 +0000 (07:47 +0200)
committerDirk Brenken <dev@brenken.org>
Thu, 27 Jun 2024 05:47:10 +0000 (07:47 +0200)
* made the DNS Reporting / tcpdump parsing code more capable
* small init fixes
* update readme

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/adblock/Makefile
net/adblock/files/README.md
net/adblock/files/adblock.init
net/adblock/files/adblock.sh

index 5d30ae44ee93c3c59c3eab832a10790d39edde16..e67f873957857f9e0122e56504ab598fe6eec452 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
 PKG_VERSION:=4.1.5
-PKG_RELEASE:=9
+PKG_RELEASE:=10
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 463965b0f10ca8c801720abe7e1440e2cf3a9a57..a481c51f2e3684a1a94fab5b291126e55c04ba41 100644 (file)
@@ -309,6 +309,19 @@ Add an unique object name, make the required changes to 'url', 'rule', 'size' an
 ## Support
 Please join the adblock discussion in this [forum thread](https://forum.openwrt.org/t/adblock-support-thread/507) or contact me by mail <dev@brenken.org>
 
+## Removal
+Stop all adblock related services with _/etc/init.d/adblock stop_ and remove the adblock package if necessary.
+
+## Donations
+You like this project - is there a way to donate? Generally speaking "No" - I have a well-paying full-time job and my OpenWrt projects are just a hobby of mine in my spare time.  
+
+If you still insist to donate some bucks ...  
+* I would be happy if you put your money in kind into other, social projects in your area, e.g. a children's hospice
+* Let's meet and invite me for a coffee if you are in my area, the “Markgräfler Land” in southern Germany or in Switzerland (Basel)
+* Send your money to my [PayPal account](https://www.paypal.me/DirkBrenken) and I will collect your donations over the year to support various social projects in my area
+
+No matter what you decide - thank you very much for your support!  
+
 Have fun!  
 Dirk
 
index 947e2f6cece7fe480aec32184b3b8603f656e76d..06171f33a32448bb90040b51260077938dc0c0d6 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/sh /etc/rc.common
-# Copyright (c) 2015-2022 Dirk Brenken (dev@brenken.org)
+# Copyright (c) 2015-2024 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
-# disable (s)hellcheck in release
+# (s)hellcheck exceptions
 # shellcheck disable=all
 
 START=30
@@ -19,16 +19,12 @@ adb_init="/etc/init.d/adblock"
 adb_script="/usr/bin/adblock.sh"
 adb_pidfile="/var/run/adblock.pid"
 
-if [ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] ||
-       [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] ||
-       [ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] ||
-       { [ "${action}" = "list" ] && [ -n "${1}" ]; }; }; then
-       return 0
-fi
+[ "${action}" = "boot" ] && "${adb_init}" running && exit 0
+[ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] || [ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] || { [ "${action}" = "list" ] && [ -n "${1}" ]; }; } && exit 1
 
 boot() {
-       [ -s "${adb_pidfile}" ] && : >"${adb_pidfile}"
-       rc_procd start_service
+       : >"${adb_pidfile}"
+       rc_procd start_service "boot"
 }
 
 start_service() {
index 5a28ec7b0a66be2541411b7b8be4a55f8923f2ac..8b6527cfe140fd9b05cd454b9438c832c08397ba 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2015-2024 Dirk Brenken (dev@brenken.org)
 # This is free software, licensed under the GNU General Public License v3.
 
-# disable (s)hellcheck in release
+# (s)hellcheck exceptions
 # shellcheck disable=all
 
 # set initial defaults
@@ -1306,12 +1306,22 @@ f_report() {
                        (
                                if [ "${adb_repiface}" = "any" ]; then
                                        "${adb_dumpcmd}" "${resolve}" -tttt -r "${file}" 2>/dev/null |
-                                               "${adb_awk}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? /&&/ A[\? ]+|NXDomain|0\.0\.0\.0/{a=$1;b=substr($2,0,8);c=$6;sub(/\.[0-9]+$/,"",c);gsub(/[^[:alnum:]\.:-]/,"",c);d=cnt $9;sub(/\*$/,"",d);
-                                               e=$(NF-1);sub(/[0-9]\/[0-9]\/[0-9]|0\.0\.0\.0/,"NX",e);sub(/\.$/,"",e);sub(/([0-9]{1,3}\.){3}[0-9]{1,3}/,"OK",e);gsub(/[^[:alnum:]\.-]/,"",e);if(e==""){e="err"};printf "%s\t%s\t%s\t%s\t%s\n",d,e,a,b,c}' >>"${report_raw}"
+                                       "${adb_awk}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? | Flags /&&/ A[A]*\? |NXDomain|0\.0\.0\.0|[0-9]\/[0-9]\/[0-9]/{sub(/\.[0-9]+$/,"",$6);
+                                               type=substr($(NF-1),length($(NF-1)));
+                                               if(type=="."&&$(NF-2)!="CNAME")
+                                                       {domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
+                                               else
+                                                       {if($(NF-1)~/[0-9]\/[0-9]\/[0-9]/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
+                                               printf "%08d\t%s\t%s\t%s\t%-25s\t%s\n",$9,type,$1,substr($2,1,8),$6,domain}' >>"${report_raw}"
                                else
-                                       "${adb_dumpcmd}" "${resolve}" -tttt -r "${file}" 2>/dev/null |
-                                               "${adb_awk}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? /&&/ A[\? ]+|NXDomain|0\.0\.0\.0/{a=$1;b=substr($2,0,8);c=$4;sub(/\.[0-9]+$/,"",c);gsub(/[^[:alnum:]\.:-]/,"",c);d=cnt $7;sub(/\*$/,"",d);
-                                               e=$(NF-1);sub(/[0-9]\/[0-9]\/[0-9]|0\.0\.0\.0/,"NX",e);sub(/\.$/,"",e);sub(/([0-9]{1,3}\.){3}[0-9]{1,3}/,"OK",e);gsub(/[^[:alnum:]\.-]/,"",e);if(e==""){e="err"};printf "%s\t%s\t%s\t%s\t%s\n",d,e,a,b,c}' >>"${report_raw}"
+                                       "${adb_dumpcmd}" "${resolve}"  -tttt -r "${file}" 2>/dev/null |
+                                       "${adb_awk}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? | Flags /&&/ A[A]*\? |NXDomain|0\.0\.0\.0|[0-9]\/[0-9]\/[0-9]/{sub(/\.[0-9]+$/,"",$4);
+                                               type=substr($(NF-1),length($(NF-1)));
+                                               if(type=="."&&$(NF-2)!="CNAME")
+                                                       {domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
+                                               else
+                                                       {if($(NF-1)~/[0-9]\/[0-9]\/[0-9]/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
+                                               printf "%08d\t%s\t%s\t%s\t%-25s\t%s\n",$7,type,$1,substr($2,1,8),$4,domain}' >>"${report_raw}"
                                fi
                        ) &
                        hold="$((cnt % adb_cores))"
@@ -1320,10 +1330,10 @@ f_report() {
                done
                wait
                if [ -s "${report_raw}" ]; then
-                       "${adb_sort}" ${adb_srtopts} -k1 -k3 -k4 -k5 -k1 -ur "${report_raw}" |
-                               "${adb_awk}" '{currA=($1+0);currB=$1;currC=substr($1,length($1),1);if(reqA==currB){reqA=0;printf "%s\t%s\n",d,$2}else if(currC=="+"){reqA=currA;d=$3"\t"$4"\t"$5"\t"$2}}' |
-                               "${adb_sort}" ${adb_srtopts} -k1 -k2 -k3 -k4 -ur >"${report_srt}"
-                       rm -f "${report_raw}"
+                       "${adb_sort}" ${adb_srtopts} -k3,3 -k4,4 -k1,1 -k2,2 -u -r "${report_raw}" |
+                               "${adb_awk}" '{currA=($1+0);currB=$1;currC=$2;if(reqA==currB){reqA=0;printf "%-90s\t%s\n",d,$2}else if(currC=="RQ"){reqA=currA;d=$3"\t"$4"\t"$5"\t"$6}}' |
+                               "${adb_sort}" ${adb_srtopts} -u -r >"${report_srt}"
+                       : >"${report_raw}"
                fi
 
                if [ -s "${report_srt}" ]; then
@@ -1368,7 +1378,7 @@ f_report() {
                        search="${search//./\\.}"
                        search="${search//[+*~%\$&\"\' ]/}"
                        "${adb_awk}" "BEGIN{i=0;printf \"\t\\\"requests\\\": [\n\"}/(${search})/{i++;if(i==1)printf \"\n\t\t{\n\t\t\t\\\"date\\\": \\\"%s\\\",\n\t\t\t\\\"time\\\": \\\"%s\\\",\n\t\t\t\\\"client\\\": \\\"%s\\\",\n\t\t\t\\\"domain\\\": \\\"%s\\\",\n\t\t\t\\\"rc\\\": \\\"%s\\\"\n\t\t}\",\$1,\$2,\$3,\$4,\$5;else if(i<=${res_count})printf \",\n\t\t{\n\t\t\t\\\"date\\\": \\\"%s\\\",\n\t\t\t\\\"time\\\": \\\"%s\\\",\n\t\t\t\\\"client\\\": \\\"%s\\\",\n\t\t\t\\\"domain\\\": \\\"%s\\\",\n\t\t\t\\\"rc\\\": \\\"%s\\\"\n\t\t}\",\$1,\$2,\$3,\$4,\$5}END{printf \"\n\t]\n}\n\"}" "${adb_reportdir}/adb_report.srt" >>"${report_jsn}"
-                       rm -f "${report_srt}"
+                       : >"${report_srt}"
                fi
        fi
 
@@ -1422,7 +1432,7 @@ f_report() {
                        json_select ".."
                done
                content="$(cat "${report_txt}" 2>/dev/null)"
-               rm -f "${report_txt}"
+               : >"${report_txt}"
        fi
 
        # report output