# build report
#
if [ "${action}" != "json" ]; then
- : >"${report_raw}" >"${report_srt}" >"${report_txt}" >"${report_jsn}"
+ : >"${report_raw}" >"${report_srt}" >"${report_txt}" >"${report_jsn}" >"${map_jsn}"
: >"${top_tmpclients}" >"${top_tmpdomains}" >"${top_tmpblocked}"
[ "${adb_represolve}" = "1" ] && resolve=""
for file in "${adb_reportdir}/adb_report.pcap"*; do
next
}
# ok answer
- /[0-9]+[[:space:]]+[0-9]+\/[0-9]+\/[0-9]+[[:space:]]+(A|AAAA|CNAME)[[:space:]]/ {
+ / (A|AAAA|CNAME) / && !/NXDomain/ && !/ServFail/ {
if (pending) {
printf "%s\t%s\t%s\t%s\t%s\t%s\tOK\n",
last_date, last_time, last_client, last_interface, last_qtype, last_domain
#
if [ "${adb_map}" = "1" ] && [ -s "${report_jsn}" ]; then
cnt="1"
- network_find_wan iface_v4
- network_get_ipaddr ip_v4 "${iface_v4}"
- network_find_wan6 iface_v6
- network_get_ipaddr6 ip_v6 "${iface_v6}"
- printf "%s" ",[{}" >"${map_jsn}"
- f_fetch
+ network_find_wan iface_v4 && network_get_ipaddr ip_v4 "${iface_v4}"
+ network_find_wan6 iface_v6 && network_get_ipaddr6 ip_v6 "${iface_v6}"
+ if [ -n "${ip_v4}" ] || [ -n "${ip_v6}" ]; then
+ f_fetch
+ printf "%s" ",[{}" >"${map_jsn}"
+ fi
for ip in ${ip_v4} ${ip_v6}; do
- "${adb_fetchcmd}" ${adb_geoparm} "${adb_geourl}/${ip}" 2>/dev/null |
- "${adb_awkcmd}" -v feed="homeIP" '{printf ",{\"%s\": %s}\n",feed,$0}' >>"${map_jsn}"
+ (
+ "${adb_fetchcmd}" ${adb_geoparm} "${adb_geourl}/${ip}" 2>/dev/null |
+ "${adb_awkcmd}" -v feed="homeIP" '{printf ",{\"%s\": %s}\n",feed,$0}' >>"${map_jsn}"
+ ) &
+ [ "${cnt}" -gt "${adb_cores}" ] && wait -n
cnt="$((cnt + 1))"
done
- if [ -s "${map_jsn}" ] && [ "${cnt}" -lt "45" ] && [ "$("${adb_catcmd}" "${map_jsn}")" != ",[{}" ]; then
+ wait
+ if [ -s "${map_jsn}" ] && [ "${cnt}" -lt "45" ]; then
json_init
if json_load_file "${report_jsn}" >/dev/null 2>&1; then
json_select "requests" >/dev/null 2>&1
json_get_keys requests >/dev/null 2>&1
for request in ${requests}; do
json_select "${request}" >/dev/null 2>&1
- json_get_keys details >/dev/null 2>&1
json_get_var rc "rc" >/dev/null 2>&1
json_get_var domain "domain" >/dev/null 2>&1
- if [ "${rc}" = "NX" ] && ! "${adb_catcmd}" "${map_jsn}" 2>/dev/null | "${adb_grepcmd}" -qxF "${domain}"; then
+ if [ "${rc}" = "NX" ] && ! "${adb_grepcmd}" -q "\"${domain}\":" "${map_jsn}"; then
(
"${adb_fetchcmd}" ${adb_geoparm} "${adb_geourl}/${domain}" 2>/dev/null |
"${adb_awkcmd}" -v feed="${domain}" '{printf ",{\"%s\": %s}\n",feed,$0}' >>"${map_jsn}"
printf "%s\n" "${content}"
;;
"json")
- if [ "${adb_map}" = "1" ]; then
+ if [ "${adb_map}" = "1" ] && [ -s "${map_jsn}" ]; then
jsn="$("${adb_catcmd}" ${report_jsn} ${map_jsn} 2>/dev/null)"
[ -n "${jsn}" ] && printf "[%s]]\n" "${jsn}"
else