mirror of https://github.com/openwrt/packages.git
adblock: update to 4.2.2-6
* fixed adblock status reporting * optimized the mail template * removed unanswered DNS requests from reporting * various small fixes Signed-off-by: Dirk Brenken <dev@brenken.org>pull/25120/head
parent
850b2609c6
commit
1294b54471
|
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=adblock
|
PKG_NAME:=adblock
|
||||||
PKG_VERSION:=4.2.2
|
PKG_VERSION:=4.2.2
|
||||||
PKG_RELEASE:=5
|
PKG_RELEASE:=6
|
||||||
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>
|
||||||
|
|
||||||
|
|
|
@ -133,36 +133,21 @@ status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
status_service() {
|
status_service() {
|
||||||
local key keylist value idxval values type rtfile
|
local key keylist value values rtfile
|
||||||
|
|
||||||
rtfile="$(uci_get adblock global adb_rtfile "/tmp/adb_runtime.json")"
|
rtfile="$(uci_get adblock global adb_rtfile "/tmp/adb_runtime.json")"
|
||||||
|
json_init
|
||||||
json_load_file "${rtfile}" >/dev/null 2>&1
|
json_load_file "${rtfile}" >/dev/null 2>&1
|
||||||
json_get_keys keylist
|
json_get_keys keylist
|
||||||
if [ -n "${keylist}" ]; then
|
if [ -n "${keylist}" ]; then
|
||||||
printf "%s\n" "::: adblock runtime information"
|
printf "%s\n" "::: adblock runtime information"
|
||||||
for key in ${keylist}; do
|
for key in ${keylist}; do
|
||||||
json_get_var value "${key}" >/dev/null 2>&1
|
json_get_var value "${key}" >/dev/null 2>&1
|
||||||
if [ "${key%_*}" = "active" ]; then
|
if [ "${key}" = "active_sources" ]; then
|
||||||
printf " + %-15s : " "${key}"
|
json_get_values values "${key}" >/dev/null 2>&1
|
||||||
json_select "${key}" >/dev/null 2>&1
|
value="${values// /, }"
|
||||||
values=""
|
|
||||||
index="1"
|
|
||||||
while json_get_type type "${index}" && [ "${type}" = "object" ]; do
|
|
||||||
json_get_values idxval "${index}" >/dev/null 2>&1
|
|
||||||
if [ "${index}" = "1" ]; then
|
|
||||||
values="${idxval}"
|
|
||||||
else
|
|
||||||
values="${values}, ${idxval}"
|
|
||||||
fi
|
|
||||||
index="$((index + 1))"
|
|
||||||
done
|
|
||||||
values="$(printf "%s" "${values}" | awk '{NR=1;max=98;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max)}else{printf"%-22s%s\n","",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
|
|
||||||
printf "%s\n" "${values:-"-"}"
|
|
||||||
json_select ".."
|
|
||||||
else
|
|
||||||
printf " + %-15s : %s\n" "${key}" "${value:-"-"}"
|
|
||||||
fi
|
fi
|
||||||
|
printf " + %-15s : %s\n" "${key}" "${value:-"-"}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
printf "%s\n" "::: no adblock runtime information available"
|
printf "%s\n" "::: no adblock runtime information available"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# send mail script for adblock notifications
|
# send mail script for adblock notifications
|
||||||
# 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.
|
# This is free software, licensed under the GNU General Public License v3.
|
||||||
|
|
||||||
# Please note: you have to manually install and configure the package 'msmtp' before using this script
|
# Please note: you have to manually install and configure the package 'msmtp' before using this script
|
||||||
|
@ -12,46 +12,26 @@ LC_ALL=C
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
[ -r "/lib/functions.sh" ] && . "/lib/functions.sh"
|
[ -r "/lib/functions.sh" ] && . "/lib/functions.sh"
|
||||||
|
[ -r "/usr/bin/adblock.sh" ] && . "/usr/bin/adblock.sh" "mail"
|
||||||
|
|
||||||
adb_debug="$(uci_get adblock global adb_debug "0")"
|
adb_debug="$(uci_get adblock global adb_debug "0")"
|
||||||
adb_mailsender="$(uci_get adblock global adb_mailsender "no-reply@adblock")"
|
adb_mailsender="$(uci_get adblock global adb_mailsender "no-reply@adblock")"
|
||||||
adb_mailreceiver="$(uci_get adblock global adb_mailreceiver)"
|
adb_mailreceiver="$(uci_get adblock global adb_mailreceiver)"
|
||||||
adb_mailtopic="$(uci_get adblock global adb_mailtopic "adblock notification")"
|
adb_mailtopic="$(uci_get adblock global adb_mailtopic "adblock notification")"
|
||||||
adb_mailprofile="$(uci_get adblock global adb_mailprofile "adb_notify")"
|
adb_mailprofile="$(uci_get adblock global adb_mailprofile "adb_notify")"
|
||||||
adb_ver="${1}"
|
|
||||||
adb_mail="$(command -v msmtp)"
|
|
||||||
adb_logger="$(command -v logger)"
|
|
||||||
adb_logread="$(command -v logread)"
|
|
||||||
adb_rc="1"
|
|
||||||
|
|
||||||
f_log() {
|
[ -z "${adb_mailreceiver}" ] && f_log "err" "please set the mail receiver with the 'adb_mailreceiver' option"
|
||||||
local class="${1}" log_msg="${2}"
|
|
||||||
|
|
||||||
if [ -x "${adb_logger}" ]; then
|
|
||||||
"${adb_logger}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
else
|
|
||||||
printf "%s %s %s\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "${adb_mailreceiver}" ]; then
|
|
||||||
f_log "err" "please set the mail receiver with the 'adb_mailreceiver' option"
|
|
||||||
exit ${adb_rc}
|
|
||||||
fi
|
|
||||||
[ "${adb_debug}" = "1" ] && debug="--debug"
|
[ "${adb_debug}" = "1" ] && debug="--debug"
|
||||||
|
|
||||||
adb_mailhead="From: ${adb_mailsender}\nTo: ${adb_mailreceiver}\nSubject: ${adb_mailtopic}\nReply-to: ${adb_mailsender}\nMime-Version: 1.0\nContent-Type: text/html;charset=utf-8\nContent-Disposition: inline\n\n"
|
adb_mailhead="From: ${adb_mailsender}\nTo: ${adb_mailreceiver}\nSubject: ${adb_mailtopic}\nReply-to: ${adb_mailsender}\nMime-Version: 1.0\nContent-Type: text/html;charset=utf-8\nContent-Disposition: inline\n\n"
|
||||||
|
|
||||||
# info preparation
|
# info preparation
|
||||||
#
|
#
|
||||||
sys_info="$(
|
sys_info="$("${adb_stringscmd}" /etc/banner 2>/dev/null; "${adb_ubuscmd}" call system board | "${adb_awkcmd}" 'BEGIN{FS="[{}\"]"}{if($2=="kernel"||$2=="hostname"||$2=="system"||$2=="model"||$2=="description")printf " + %-12s: %s\n",$2,$4}' 2>/dev/null)"
|
||||||
strings /etc/banner 2>/dev/null
|
|
||||||
ubus call system board | sed -e 's/\"release\": {//' | sed -e 's/^[ \t]*//' | sed -e 's/[{}\",]//g' | sed -e 's/[ ]/ \t/' | sed '/^$/d' 2>/dev/null
|
|
||||||
)"
|
|
||||||
adb_info="$(/etc/init.d/adblock status 2>/dev/null)"
|
adb_info="$(/etc/init.d/adblock status 2>/dev/null)"
|
||||||
rep_info="${2}"
|
rep_info="${1}"
|
||||||
if [ -x "${adb_logread}" ]; then
|
if [ -x "${adb_logreadcmd}" ]; then
|
||||||
log_info="$("${adb_logread}" -l 100 -e "adblock-" | awk '{NR=1;max=120;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max)}else{print substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
|
log_info="$("${adb_logreadcmd}" -l 100 -e "adblock-" | "${adb_awkcmd}" '{NR=1;max=120;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max)}else{print substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# mail body
|
# mail body
|
||||||
|
@ -67,11 +47,9 @@ adb_mailtext="${adb_mailtext}</pre></body></html>"
|
||||||
|
|
||||||
# send mail
|
# send mail
|
||||||
#
|
#
|
||||||
if [ -x "${adb_mail}" ]; then
|
if [ -x "${adb_mailcmd}" ]; then
|
||||||
printf "%b" "${adb_mailhead}${adb_mailtext}" 2>/dev/null | "${adb_mail}" ${debug} -a "${adb_mailprofile}" "${adb_mailreceiver}" >/dev/null 2>&1
|
printf "%b" "${adb_mailhead}${adb_mailtext}" 2>/dev/null | "${adb_mailcmd}" ${debug} -a "${adb_mailprofile}" "${adb_mailreceiver}" >/dev/null 2>&1
|
||||||
adb_rc=${?}
|
f_log "info" "mail sent to '${adb_mailreceiver}' with rc '${?}'"
|
||||||
f_log "info" "mail sent to '${adb_mailreceiver}' with rc '${adb_rc}'"
|
|
||||||
else
|
else
|
||||||
f_log "err" "msmtp mail daemon not found"
|
f_log "err" "msmtp mail daemon not found"
|
||||||
fi
|
fi
|
||||||
exit ${adb_rc}
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
adb_ver="4.2.2-r5"
|
adb_ver="4.2.2-r6"
|
||||||
adb_enabled="0"
|
adb_enabled="0"
|
||||||
adb_debug="0"
|
adb_debug="0"
|
||||||
adb_forcedns="0"
|
adb_forcedns="0"
|
||||||
|
@ -255,7 +255,7 @@ f_dns() {
|
||||||
if [ -z "${adb_dns}" ]; then
|
if [ -z "${adb_dns}" ]; then
|
||||||
utils="knot-resolver bind unbound dnsmasq raw"
|
utils="knot-resolver bind unbound dnsmasq raw"
|
||||||
for util in ${utils}; do
|
for util in ${utils}; do
|
||||||
if [ "${util}" = "raw" ] || printf "%s" "${adb_packages}" | grep -q "^${util}"; then
|
if [ "${util}" = "raw" ] || printf "%s" "${adb_packages}" | "${adb_grepcmd}" -q "^${util}"; then
|
||||||
if [ "${util}" = "knot-resolver" ]; then
|
if [ "${util}" = "knot-resolver" ]; then
|
||||||
util="kresd"
|
util="kresd"
|
||||||
elif [ "${util}" = "bind" ]; then
|
elif [ "${util}" = "bind" ]; then
|
||||||
|
@ -401,8 +401,8 @@ f_fetch() {
|
||||||
if [ -z "${adb_fetchutil}" ]; then
|
if [ -z "${adb_fetchutil}" ]; then
|
||||||
utils="aria2c curl wget uclient-fetch"
|
utils="aria2c curl wget uclient-fetch"
|
||||||
for util in ${utils}; do
|
for util in ${utils}; do
|
||||||
if { [ "${util}" = "uclient-fetch" ] && printf "%s" "${adb_packages}" | grep -q "^libustream-"; } ||
|
if { [ "${util}" = "uclient-fetch" ] && printf "%s" "${adb_packages}" | "${adb_grepcmd}" -q "^libustream-"; } ||
|
||||||
{ [ "${util}" = "wget" ] && printf "%s" "${adb_packages}" | grep -q "^wget -"; } ||
|
{ [ "${util}" = "wget" ] && printf "%s" "${adb_packages}" | "${adb_grepcmd}" -q "^wget -"; } ||
|
||||||
[ "${util}" = "curl" ] || [ "${util}" = "aria2c" ]; then
|
[ "${util}" = "curl" ] || [ "${util}" = "aria2c" ]; then
|
||||||
if [ -x "$(command -v "${util}")" ]; then
|
if [ -x "$(command -v "${util}")" ]; then
|
||||||
adb_fetchutil="${util}"
|
adb_fetchutil="${util}"
|
||||||
|
@ -542,7 +542,7 @@ f_count() {
|
||||||
adb_cnt="$((adb_cnt - $(wc -l 2>/dev/null <"${file}")))"
|
adb_cnt="$((adb_cnt - $(wc -l 2>/dev/null <"${file}")))"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ -n "${adb_dnsheader}" ] && adb_cnt="$(((adb_cnt - $(printf "%b" "${adb_dnsheader}" | grep -c "^")) / 2))"
|
[ -n "${adb_dnsheader}" ] && adb_cnt="$(((adb_cnt - $(printf "%b" "${adb_dnsheader}" | "${adb_grepcmd}" -c "^")) / 2))"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -556,14 +556,14 @@ f_extconf() {
|
||||||
case "${adb_dns}" in
|
case "${adb_dns}" in
|
||||||
"dnsmasq")
|
"dnsmasq")
|
||||||
config="dhcp"
|
config="dhcp"
|
||||||
config_dir="$(uci_get dhcp "@dnsmasq[${adb_dnsinstance}]" confdir | grep -Fo "${adb_dnsdir}")"
|
config_dir="$(uci_get dhcp "@dnsmasq[${adb_dnsinstance}]" confdir | "${adb_grepcmd}" -Fo "${adb_dnsdir}")"
|
||||||
if [ "${adb_enabled}" = "1" ] && [ -z "${config_dir}" ]; then
|
if [ "${adb_enabled}" = "1" ] && [ -z "${config_dir}" ]; then
|
||||||
uci_set dhcp "@dnsmasq[${adb_dnsinstance}]" confdir "${adb_dnsdir}" 2>/dev/null
|
uci_set dhcp "@dnsmasq[${adb_dnsinstance}]" confdir "${adb_dnsdir}" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"kresd")
|
"kresd")
|
||||||
config="resolver"
|
config="resolver"
|
||||||
config_file="$(uci_get resolver kresd rpz_file | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")"
|
config_file="$(uci_get resolver kresd rpz_file | "${adb_grepcmd}" -Fo "${adb_dnsdir}/${adb_dnsfile}")"
|
||||||
if [ "${adb_enabled}" = "1" ] && [ -z "${config_file}" ]; then
|
if [ "${adb_enabled}" = "1" ] && [ -z "${config_file}" ]; then
|
||||||
uci -q add_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
|
uci -q add_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
|
||||||
elif [ "${adb_enabled}" = "0" ] && [ -n "${config_file}" ]; then
|
elif [ "${adb_enabled}" = "0" ] && [ -n "${config_file}" ]; then
|
||||||
|
@ -579,7 +579,7 @@ f_extconf() {
|
||||||
/etc/init.d/firewall enabled; then
|
/etc/init.d/firewall enabled; then
|
||||||
for zone in ${adb_zonelist}; do
|
for zone in ${adb_zonelist}; do
|
||||||
for port in ${adb_portlist}; do
|
for port in ${adb_portlist}; do
|
||||||
if ! printf "%s" "${fwcfg}" | grep -q "adblock_${zone}${port}[ |\$]"; then
|
if ! printf "%s" "${fwcfg}" | "${adb_grepcmd}" -q "adblock_${zone}${port}[ |\$]"; then
|
||||||
uci -q batch <<-EOC
|
uci -q batch <<-EOC
|
||||||
set firewall."adblock_${zone}${port}"="redirect"
|
set firewall."adblock_${zone}${port}"="redirect"
|
||||||
set firewall."adblock_${zone}${port}".name="Adblock DNS (${zone}, ${port})"
|
set firewall."adblock_${zone}${port}".name="Adblock DNS (${zone}, ${port})"
|
||||||
|
@ -1026,7 +1026,7 @@ f_query() {
|
||||||
# update runtime information
|
# update runtime information
|
||||||
#
|
#
|
||||||
f_jsnup() {
|
f_jsnup() {
|
||||||
local entry sources runtime utils bg_pid status="${1:-"enabled"}"
|
local object sources runtime utils bg_pid status="${1:-"enabled"}"
|
||||||
|
|
||||||
adb_memory="$("${adb_awkcmd}" '/^MemTotal|^MemFree|^MemAvailable/{ORS="/"; print int($2/1000)}' "/proc/meminfo" 2>/dev/null |
|
adb_memory="$("${adb_awkcmd}" '/^MemTotal|^MemFree|^MemAvailable/{ORS="/"; print int($2/1000)}' "/proc/meminfo" 2>/dev/null |
|
||||||
"${adb_awkcmd}" '{print substr($0,1,length($0)-1)}')"
|
"${adb_awkcmd}" '{print substr($0,1,length($0)-1)}')"
|
||||||
|
@ -1064,15 +1064,12 @@ f_jsnup() {
|
||||||
: >"${adb_rtfile}"
|
: >"${adb_rtfile}"
|
||||||
json_init
|
json_init
|
||||||
json_load_file "${adb_rtfile}" >/dev/null 2>&1
|
json_load_file "${adb_rtfile}" >/dev/null 2>&1
|
||||||
json_init
|
|
||||||
json_add_string "adblock_status" "${status:-"enabled"}"
|
json_add_string "adblock_status" "${status:-"enabled"}"
|
||||||
json_add_string "adblock_version" "${adb_ver}"
|
json_add_string "adblock_version" "${adb_ver}"
|
||||||
json_add_string "blocked_domains" "${adb_cnt:-0}"
|
json_add_string "blocked_domains" "${adb_cnt:-0}"
|
||||||
json_add_array "active_sources"
|
json_add_array "active_sources"
|
||||||
for entry in ${sources}; do
|
for object in ${sources:-"-"}; do
|
||||||
json_add_object
|
json_add_string "${object}" "${object}"
|
||||||
json_add_string "source" "${entry}"
|
|
||||||
json_close_object
|
|
||||||
done
|
done
|
||||||
json_close_array
|
json_close_array
|
||||||
json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}"
|
json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}"
|
||||||
|
@ -1085,9 +1082,8 @@ f_jsnup() {
|
||||||
json_dump >"${adb_rtfile}"
|
json_dump >"${adb_rtfile}"
|
||||||
|
|
||||||
if [ "${adb_mail}" = "1" ] && [ -x "${adb_mailservice}" ] &&
|
if [ "${adb_mail}" = "1" ] && [ -x "${adb_mailservice}" ] &&
|
||||||
{ [ "${status}" = "error" ] || { [ "${status}" = "enabled" ] && [ "${adb_cnt}" -le "${adb_mailcnt}" ]; }; }; then
|
[ "${status}" = "enabled" ] && [ "${adb_cnt}" -le "${adb_mailcnt}" ]; then
|
||||||
("${adb_mailservice}" "${adb_ver}" >/dev/null 2>&1) &
|
"${adb_mailservice}" >/dev/null 2>&1
|
||||||
bg_pid="${!}"
|
|
||||||
fi
|
fi
|
||||||
f_log "debug" "f_jsnup ::: status: ${status:-"-"}, cnt: ${adb_cnt}, mail: ${adb_mail}, mail_service: ${adb_mailservice}, mail_cnt: ${adb_mailcnt}, mail_pid: ${bg_pid:-"-"}"
|
f_log "debug" "f_jsnup ::: status: ${status:-"-"}, cnt: ${adb_cnt}, mail: ${adb_mail}, mail_service: ${adb_mailservice}, mail_cnt: ${adb_mailcnt}, mail_pid: ${bg_pid:-"-"}"
|
||||||
}
|
}
|
||||||
|
@ -1101,7 +1097,7 @@ f_log() {
|
||||||
[ -x "${adb_loggercmd}" ] && "${adb_loggercmd}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}" || \
|
[ -x "${adb_loggercmd}" ] && "${adb_loggercmd}" -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}" || \
|
||||||
printf "%s %s %s\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
printf "%s %s %s\n" "${class}" "adblock-${adb_ver}[${$}]" "${log_msg}"
|
||||||
if [ "${class}" = "err" ] || [ "${class}" = "emerg" ]; then
|
if [ "${class}" = "err" ] || [ "${class}" = "emerg" ]; then
|
||||||
f_rmdns
|
[ "${adb_action}" != "mail" ] && f_rmdns
|
||||||
f_jsnup "error"
|
f_jsnup "error"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1199,7 +1195,7 @@ f_main() {
|
||||||
src_suffix="$(eval printf "%s" \"\$\{adb_src_suffix_${src_name}:-\"domains\"\}\")"
|
src_suffix="$(eval printf "%s" \"\$\{adb_src_suffix_${src_name}:-\"domains\"\}\")"
|
||||||
src_list="$(tar -tzf "${src_arc}" 2>/dev/null)"
|
src_list="$(tar -tzf "${src_arc}" 2>/dev/null)"
|
||||||
for src_item in ${src_cat}; do
|
for src_item in ${src_cat}; do
|
||||||
src_entries="${src_entries} $(printf "%s" "${src_list}" | grep -E "${src_item}/${src_suffix}$")"
|
src_entries="${src_entries} $(printf "%s" "${src_list}" | "${adb_grepcmd}" -E "${src_item}/${src_suffix}$")"
|
||||||
done
|
done
|
||||||
if [ -n "${src_entries}" ]; then
|
if [ -n "${src_entries}" ]; then
|
||||||
tar -xOzf "${src_arc}" ${src_entries} 2>/dev/null >"${src_tmpload}"
|
tar -xOzf "${src_arc}" ${src_entries} 2>/dev/null >"${src_tmpload}"
|
||||||
|
@ -1330,8 +1326,8 @@ f_report() {
|
||||||
{domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
|
{domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
|
||||||
else
|
else
|
||||||
{if($(NF-2)~/NXDomain/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
|
{if($(NF-2)~/NXDomain/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
|
||||||
if(int($9)>0)
|
if(int($9)>0)
|
||||||
printf "%08d\t%s\t%s\t%s\t%-25s\t%s\n",$9,type,$1,substr($2,1,8),$6,domain}' >>"${report_raw}"
|
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
|
else
|
||||||
"${adb_dumpcmd}" "${resolve}" --immediate-mode -T domain -tttt -r "${file}" 2>/dev/null |
|
"${adb_dumpcmd}" "${resolve}" --immediate-mode -T domain -tttt -r "${file}" 2>/dev/null |
|
||||||
"${adb_awkcmd}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? | Flags /&&/ A[A]*\? |NXDomain|0\.0\.0\.0|[0-9]\/[0-9]\/[0-9]/{sub(/\.[0-9]+$/,"",$4);
|
"${adb_awkcmd}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? | Flags /&&/ A[A]*\? |NXDomain|0\.0\.0\.0|[0-9]\/[0-9]\/[0-9]/{sub(/\.[0-9]+$/,"",$4);
|
||||||
|
@ -1340,8 +1336,8 @@ f_report() {
|
||||||
{domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
|
{domain=substr($(NF-1),1,length($(NF-1))-1);type="RQ"}
|
||||||
else
|
else
|
||||||
{if($(NF-2)~/NXDomain/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
|
{if($(NF-2)~/NXDomain/||$(NF-1)=="0.0.0.0"){type="NX"}else{type="OK"};domain=""};
|
||||||
if(int($7)>0)
|
if(int($7)>0)
|
||||||
printf "%08d\t%s\t%s\t%s\t%-25s\t%s\n",$7,type,$1,substr($2,1,8),$4,domain}' >>"${report_raw}"
|
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
|
fi
|
||||||
) &
|
) &
|
||||||
hold="$((cnt % adb_cores))"
|
hold="$((cnt % adb_cores))"
|
||||||
|
@ -1352,7 +1348,7 @@ f_report() {
|
||||||
if [ -s "${report_raw}" ]; then
|
if [ -s "${report_raw}" ]; then
|
||||||
"${adb_sortcmd}" ${adb_srtopts} -k3,3 -k4,4 -k1,1 -k2,2 -u -r "${report_raw}" |
|
"${adb_sortcmd}" ${adb_srtopts} -k3,3 -k4,4 -k1,1 -k2,2 -u -r "${report_raw}" |
|
||||||
"${adb_awkcmd}" '{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_awkcmd}" '{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_sortcmd}" ${adb_srtopts} -u -r >"${report_srt}"
|
"${adb_grepcmd}" -v "RQ" | "${adb_sortcmd}" ${adb_srtopts} -u -r >"${report_srt}"
|
||||||
: >"${report_raw}"
|
: >"${report_raw}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1462,8 +1458,7 @@ f_report() {
|
||||||
elif [ "${action}" = "json" ]; then
|
elif [ "${action}" = "json" ]; then
|
||||||
cat "${report_jsn}"
|
cat "${report_jsn}"
|
||||||
elif [ "${action}" = "mail" ] && [ "${adb_mail}" = "1" ] && [ -x "${adb_mailservice}" ]; then
|
elif [ "${action}" = "mail" ] && [ "${adb_mail}" = "1" ] && [ -x "${adb_mailservice}" ]; then
|
||||||
("${adb_mailservice}" "${adb_ver}" "${content}" >/dev/null 2>&1) &
|
"${adb_mailservice}" "${content}" >/dev/null 2>&1
|
||||||
bg_pid="${!}"
|
|
||||||
fi
|
fi
|
||||||
f_log "debug" "f_report ::: action: ${action}, top_count: ${top_count}, res_count: ${res_count}, search: ${search}, dump_util: ${adb_dumpcmd}, rep_dir: ${adb_reportdir}, rep_iface: ${adb_repiface:-"-"}, rep_listen: ${adb_replisten}, rep_chunksize: ${adb_repchunksize}, rep_chunkcnt: ${adb_repchunkcnt}, rep_resolve: ${adb_represolve}"
|
f_log "debug" "f_report ::: action: ${action}, top_count: ${top_count}, res_count: ${res_count}, search: ${search}, dump_util: ${adb_dumpcmd}, rep_dir: ${adb_reportdir}, rep_iface: ${adb_repiface:-"-"}, rep_listen: ${adb_replisten}, rep_chunksize: ${adb_repchunksize}, rep_chunkcnt: ${adb_repchunkcnt}, rep_resolve: ${adb_represolve}"
|
||||||
}
|
}
|
||||||
|
@ -1490,6 +1485,9 @@ adb_ubuscmd="$(f_cmd ubus)"
|
||||||
adb_loggercmd="$(f_cmd logger)"
|
adb_loggercmd="$(f_cmd logger)"
|
||||||
adb_dumpcmd="$(f_cmd tcpdump optional)"
|
adb_dumpcmd="$(f_cmd tcpdump optional)"
|
||||||
adb_lookupcmd="$(f_cmd nslookup)"
|
adb_lookupcmd="$(f_cmd nslookup)"
|
||||||
|
adb_mailcmd="$(f_cmd msmtp optional)"
|
||||||
|
adb_stringscmd="$(f_cmd strings optional)"
|
||||||
|
adb_logreadcmd="$(f_cmd logread optional)"
|
||||||
|
|
||||||
# handle different adblock actions
|
# handle different adblock actions
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue