adblock: fix another reporting bug
authorDirk Brenken <dev@brenken.org>
Mon, 13 Apr 2020 04:16:03 +0000 (06:16 +0200)
committerDirk Brenken <dev@brenken.org>
Mon, 13 Apr 2020 04:16:03 +0000 (06:16 +0200)
* add a final sort step, this fixes dns reporting with
  multiple pcap files as input

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

index c37e3bbd880337d226bf42f8cddead6e62610bfc..1ddb3a09af77449f9a62375f34f8da13860c1b79 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
 PKG_VERSION:=4.0.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index b7e7d64c66d5419049615d691c84c233852aff50..4f24a3ddce50f7192679e7c0c990b9116b878394 100755 (executable)
@@ -1467,7 +1467,9 @@ f_report()
                        if [ -s "${adb_reportdir}/adb_report.raw" ]
                        then
                                sort ${adb_srtopts} -k1 -k3 -k4 -k5 -k1 -ur "${adb_reportdir}/adb_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_reportdir}/adb_report.srt"
+                                       "${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}}' | \
+                                       sort ${adb_srtopts} -k1 -k2 -k3 -k4 -ur > "${adb_reportdir}/adb_report.srt"
+                               rm -f "${adb_reportdir}/adb_report.raw"
                        fi
 
                        if [ -s "${adb_reportdir}/adb_report.srt" ]
@@ -1510,8 +1512,8 @@ f_report()
                                search="${search//./\\.}"
                                search="${search//[+*~%\$&\"\' ]/}"
                                "${adb_awk}" "BEGIN{i=0;printf \"%s\",\"\\\"requests\\\": [ \" }/(${search})/{i++;if(i==1)printf \"\{ \\\"date\\\": \\\"%s\\\", \\\"time\\\": \\\"%s\\\", \\\"client\\\": \\\"%s\\\", \\\"domain\\\": \\\"%s\\\", \\\"rc\\\": \\\"%s\\\" }\",\$1,\$2,\$3,\$4,\$5;else if(i<=${count})printf \", { \\\"date\\\": \\\"%s\\\", \\\"time\\\": \\\"%s\\\", \\\"client\\\": \\\"%s\\\", \\\"domain\\\": \\\"%s\\\", \\\"rc\\\": \\\"%s\\\" }\",\$1,\$2,\$3,\$4,\$5}END{printf \"%s\" \" \] } }\n\"}" "${adb_reportdir}/adb_report.srt" >> "${adb_reportdir}/adb_report.json"
+                               rm -f "${adb_reportdir}/adb_report.srt"
                        fi
-                       rm -f "${adb_reportdir}/adb_report.raw" "${adb_reportdir}/adb_report.srt"
                fi
 
                if [ -s "${adb_reportdir}/adb_report.json" ]