mirror of
https://github.com/openwrt/packages.git
synced 2026-05-31 06:51:51 +08:00
adblock: update 4.5.5-5
- f_etag performance optimization: single-pass awk consolidating count+match - f_report: minor performance optimization - LuCI: prevent possible report refresh timeouts Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=adblock
|
PKG_NAME:=adblock
|
||||||
PKG_VERSION:=4.5.5
|
PKG_VERSION:=4.5.5
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
PKG_LICENSE:=GPL-3.0-or-later
|
PKG_LICENSE:=GPL-3.0-or-later
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
||||||
|
|||||||
@@ -821,7 +821,7 @@ f_dnsup() {
|
|||||||
# handle etag http header
|
# handle etag http header
|
||||||
#
|
#
|
||||||
f_etag() {
|
f_etag() {
|
||||||
local http_head http_code etag_id etag_cnt out_rc="4" feed="${1}" feed_url="${2}" feed_suffix="${3}" feed_cnt="${4:-"1"}"
|
local http_head http_code etag_id etag_cnt etag_match out_rc="4" feed="${1}" feed_url="${2}" feed_suffix="${3}" feed_cnt="${4:-"1"}"
|
||||||
|
|
||||||
if [ -n "${adb_etagparm}" ]; then
|
if [ -n "${adb_etagparm}" ]; then
|
||||||
|
|
||||||
@@ -848,16 +848,20 @@ f_etag() {
|
|||||||
|
|
||||||
# compare http code and etag id with stored values, update etag file and return code accordingly
|
# compare http code and etag id with stored values, update etag file and return code accordingly
|
||||||
#
|
#
|
||||||
etag_cnt="$("${adb_awkcmd}" -v f="${feed}" '$1 == f { n++ } END { print n+0 }' "${adb_backupdir}/adblock.etag")"
|
etag_cnt="$("${adb_awkcmd}" -v f="${feed}" -v s="${feed_suffix}" -v e="${etag_id}" '
|
||||||
if [ "${http_code}" = "200" ] && [ "${etag_cnt}" = "${feed_cnt}" ] && [ -n "${etag_id}" ] &&
|
BEGIN { matched = 0; cnt = 0; p = f " " s }
|
||||||
"${adb_awkcmd}" -v f="${feed}" -v s="${feed_suffix}" -v e="${etag_id}" '
|
$1 == f { cnt++ }
|
||||||
BEGIN { rc = 1; p = f " " s }
|
index($0, p) == 1 {
|
||||||
index($0, p) == 1 {
|
rest = substr($0, length(p) + 1)
|
||||||
rest = substr($0, length(p) + 1)
|
sub(/^[[:space:]]+/, "", rest)
|
||||||
sub(/^[[:space:]]+/, "", rest)
|
if (rest == e) { matched = 1 }
|
||||||
if (rest == e) { rc = 0; exit }
|
}
|
||||||
}
|
END { print cnt; exit !matched }' "${adb_backupdir}/adblock.etag")"
|
||||||
END { exit rc }' "${adb_backupdir}/adblock.etag"; then
|
etag_match="${?}"
|
||||||
|
|
||||||
|
# compare http code, etag count and etag id; update etag file and return code accordingly
|
||||||
|
#
|
||||||
|
if [ "${http_code}" = "200" ] && [ "${etag_cnt}" = "${feed_cnt}" ] && [ -n "${etag_id}" ] && [ "${etag_match}" = "0" ]; then
|
||||||
out_rc="0"
|
out_rc="0"
|
||||||
elif [ -n "${etag_id}" ]; then
|
elif [ -n "${etag_id}" ]; then
|
||||||
|
|
||||||
@@ -869,8 +873,8 @@ f_etag() {
|
|||||||
"${adb_backupdir}/adblock.etag" >"${adb_backupdir}/adblock.etag.new"
|
"${adb_backupdir}/adblock.etag" >"${adb_backupdir}/adblock.etag.new"
|
||||||
else
|
else
|
||||||
"${adb_awkcmd}" -v f="${feed}" -v s="${feed_suffix}" '
|
"${adb_awkcmd}" -v f="${feed}" -v s="${feed_suffix}" '
|
||||||
BEGIN { p = f " " s }
|
BEGIN { p = f " " s }
|
||||||
index($0, p) != 1' \
|
index($0, p) != 1' \
|
||||||
"${adb_backupdir}/adblock.etag" >"${adb_backupdir}/adblock.etag.new"
|
"${adb_backupdir}/adblock.etag" >"${adb_backupdir}/adblock.etag.new"
|
||||||
fi
|
fi
|
||||||
"${adb_mvcmd}" -f "${adb_backupdir}/adblock.etag.new" "${adb_backupdir}/adblock.etag"
|
"${adb_mvcmd}" -f "${adb_backupdir}/adblock.etag.new" "${adb_backupdir}/adblock.etag"
|
||||||
@@ -2046,6 +2050,7 @@ f_report() {
|
|||||||
: >"${report_srt}" >"${report_txt}" >"${report_jsn}" >"${map_jsn}"
|
: >"${report_srt}" >"${report_txt}" >"${report_jsn}" >"${map_jsn}"
|
||||||
: >"${top_tmpclients}" >"${top_tmpdomains}" >"${top_tmpblocked}"
|
: >"${top_tmpclients}" >"${top_tmpdomains}" >"${top_tmpblocked}"
|
||||||
[ "${adb_represolve}" = "1" ] && resolve=""
|
[ "${adb_represolve}" = "1" ] && resolve=""
|
||||||
|
[ "${action}" = "gen" ] && printf '%s\n' "0" >"${adb_rundir}/adblock.report"
|
||||||
cnt="1"
|
cnt="1"
|
||||||
for file in "${adb_reportdir}/adb_report.pcap"*; do
|
for file in "${adb_reportdir}/adb_report.pcap"*; do
|
||||||
[ -s "${file}" ] || continue
|
[ -s "${file}" ] || continue
|
||||||
|
|||||||
Reference in New Issue
Block a user