commit
ea9400988d
3 changed files with 70 additions and 22 deletions
|
@ -6,8 +6,8 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=adblock
|
PKG_NAME:=adblock
|
||||||
PKG_VERSION:=2.8.3
|
PKG_VERSION:=2.8.5
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=GPL-3.0+
|
PKG_LICENSE:=GPL-3.0+
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
|
||||||
* => daily updates, approx. 440 entries
|
* => daily updates, approx. 440 entries
|
||||||
* zero-conf like automatic installation & setup, usually no manual changes needed
|
* zero-conf like automatic installation & setup, usually no manual changes needed
|
||||||
* simple but yet powerful adblock engine: adblock does not use error prone external iptables rulesets, http pixel server instances and things like that
|
* simple but yet powerful adblock engine: adblock does not use error prone external iptables rulesets, http pixel server instances and things like that
|
||||||
* automatically selects dnsmasq, unbound or bind as dns backend
|
* automatically selects dnsmasq, unbound, bind or kresd (experimental!) as dns backend.
|
||||||
* automatically selects uclient-fetch or wget as download utility (other tools like curl or aria2c are supported as well)
|
* automatically selects uclient-fetch or wget as download utility (other tools like curl or aria2c are supported as well)
|
||||||
* support http only mode (without installed ssl library) for all non-SSL blocklist sources
|
* support http only mode (without installed ssl library) for all non-SSL blocklist sources
|
||||||
* automatically supports a wide range of router modes, even AP modes are supported
|
* automatically supports a wide range of router modes, even AP modes are supported
|
||||||
|
@ -157,6 +157,32 @@ create the new file '/etc/bind/db.rpz' and add:
|
||||||
$INCLUDE /var/lib/bind/adb_list.overall
|
$INCLUDE /var/lib/bind/adb_list.overall
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
|
**change default dns backend to 'kresd':**
|
||||||
|
<pre><code>
|
||||||
|
The knot-resolver (kresd) support is only available to turris omnia users. At this stage there's no package for kresd in the official LEDE / OpenWrt package repository.
|
||||||
|
Adblock deposits the sorted and filtered block list (adb_list.overall) in '/tmp/kresd' where kresd can find them.
|
||||||
|
To use the block list please modify the following kresd configuration files (experimental / untested!):
|
||||||
|
|
||||||
|
edit '/etc/config/resolver' and uncomment the following option:
|
||||||
|
option include_config '/etc/kresd/custom.conf'
|
||||||
|
|
||||||
|
in the same file change the 'forward_upstream' option like that:
|
||||||
|
forward_upstream '0'
|
||||||
|
|
||||||
|
edit '/etc/kresd/custom.conf' and add:
|
||||||
|
policy.add(policy.rpz(policy.DENY, '/etc/kresd/db.rpz'))
|
||||||
|
policy.add(policy.all(policy.FORWARD('8.8.8.8')))
|
||||||
|
policy.add(policy.all(policy.FORWARD('8.8.4.4')))
|
||||||
|
|
||||||
|
create the new file '/etc/kresd/db.rpz' and add:
|
||||||
|
$TTL 2h
|
||||||
|
$ORIGIN rpz.
|
||||||
|
@ SOA localhost. root.localhost. (1 6h 1h 1w 2h)
|
||||||
|
NS localhost.
|
||||||
|
|
||||||
|
$INCLUDE /tmp/kresd/adb_list.overall
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
**configuration for different download utilities:**
|
**configuration for different download utilities:**
|
||||||
<pre><code>
|
<pre><code>
|
||||||
wget (default):
|
wget (default):
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
adb_ver="2.8.3"
|
adb_ver="2.8.5"
|
||||||
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
|
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
|
||||||
adb_enabled=1
|
adb_enabled=1
|
||||||
adb_debug=0
|
adb_debug=0
|
||||||
|
@ -24,7 +24,7 @@ adb_whitelist="/etc/adblock/adblock.whitelist"
|
||||||
adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}"
|
adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}"
|
||||||
adb_fetch="/usr/bin/wget"
|
adb_fetch="/usr/bin/wget"
|
||||||
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O"
|
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O"
|
||||||
adb_dnslist="dnsmasq unbound named"
|
adb_dnslist="dnsmasq unbound named kresd"
|
||||||
adb_dnsprefix="adb_list"
|
adb_dnsprefix="adb_list"
|
||||||
adb_dnsfile="${adb_dnsprefix}.overall"
|
adb_dnsfile="${adb_dnsprefix}.overall"
|
||||||
adb_rtfile="/tmp/adb_runtime.json"
|
adb_rtfile="/tmp/adb_runtime.json"
|
||||||
|
@ -121,6 +121,13 @@ f_envload()
|
||||||
adb_dnsformat="awk '{print \"\"\$0\" IN CNAME .\n*.\"\$0\" IN CNAME .\"}'"
|
adb_dnsformat="awk '{print \"\"\$0\" IN CNAME .\n*.\"\$0\" IN CNAME .\"}'"
|
||||||
break 2
|
break 2
|
||||||
;;
|
;;
|
||||||
|
kresd)
|
||||||
|
adb_dns="${dns}"
|
||||||
|
adb_dnsdir="${adb_dnsdir:="/tmp/kresd"}"
|
||||||
|
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
|
||||||
|
adb_dnsformat="awk '{print \"\"\$0\" CNAME .\n*.\"\$0\" CNAME .\"}'"
|
||||||
|
break 2
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -313,12 +320,19 @@ f_list()
|
||||||
fi
|
fi
|
||||||
adb_rc=${?}
|
adb_rc=${?}
|
||||||
;;
|
;;
|
||||||
|
merge)
|
||||||
|
if [ -s "${adb_tmpfile}" ]
|
||||||
|
then
|
||||||
|
cat "${adb_tmpfile}" >> "${adb_tmpdir}/${adb_dnsfile}"
|
||||||
|
adb_rc=${?}
|
||||||
|
fi
|
||||||
|
;;
|
||||||
format)
|
format)
|
||||||
if [ -s "${adb_tmpdir}/tmp.whitelist" ]
|
if [ -s "${adb_tmpdir}/tmp.whitelist" ]
|
||||||
then
|
then
|
||||||
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" | eval "${adb_dnsformat}" >> "${adb_tmpdir}/${adb_dnsfile}"
|
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpdir}/${adb_dnsfile}" | eval "${adb_dnsformat}" > "${adb_dnsdir}/${adb_dnsfile}"
|
||||||
else
|
else
|
||||||
eval "${adb_dnsformat}" "${adb_tmpfile}" >> "${adb_tmpdir}/${adb_dnsfile}"
|
eval "${adb_dnsformat}" "${adb_tmpdir}/${adb_dnsfile}" > "${adb_dnsdir}/${adb_dnsfile}"
|
||||||
fi
|
fi
|
||||||
adb_rc=${?}
|
adb_rc=${?}
|
||||||
;;
|
;;
|
||||||
|
@ -326,6 +340,18 @@ f_list()
|
||||||
f_log "debug" "name: ${src_name}, mode: ${mode}, count: ${cnt}, in_rc: ${in_rc}, out_rc: ${adb_rc}"
|
f_log "debug" "name: ${src_name}, mode: ${mode}, count: ${cnt}, in_rc: ${in_rc}, out_rc: ${adb_rc}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# f_tldcompression: top level domain compression
|
||||||
|
#
|
||||||
|
f_tldcompression()
|
||||||
|
{
|
||||||
|
local source="${1}" temp="${adb_tmpload}"
|
||||||
|
|
||||||
|
awk -F "." '{for(f=NF;f > 1;f--) printf "%s.", $f;print $1}' "${source}" 2>/dev/null | sort -u > "${temp}"
|
||||||
|
awk '{if(NR==1){tld=$NF};while(getline){if($NF !~ tld"\\."){print tld;tld=$NF}}print tld}' "${temp}" 2>/dev/null > "${source}"
|
||||||
|
awk -F "." '{for(f=NF;f > 1;f--) printf "%s.", $f;print $1}' "${source}" 2>/dev/null > "${temp}"
|
||||||
|
sort -u "${temp}" > "${source}"
|
||||||
|
}
|
||||||
|
|
||||||
# f_switch: suspend/resume adblock processing
|
# f_switch: suspend/resume adblock processing
|
||||||
#
|
#
|
||||||
f_switch()
|
f_switch()
|
||||||
|
@ -460,14 +486,14 @@ f_main()
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# manual mode
|
# manual / backup mode
|
||||||
#
|
#
|
||||||
if [ ${adb_manmode} -eq 1 ] && [ -z "${adb_action}" ] && [ "${src_name}" != "blacklist" ]
|
if [ ${adb_manmode} -eq 1 ] && [ -z "${adb_action}" ] && [ "${src_name}" != "blacklist" ]
|
||||||
then
|
then
|
||||||
f_list restore
|
f_list restore
|
||||||
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ]
|
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ]
|
||||||
then
|
then
|
||||||
f_list format
|
f_list merge
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -502,17 +528,14 @@ f_main()
|
||||||
adb_rc=${?}
|
adb_rc=${?}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check download result and prepare domain output (incl. tld compression, list backup & restore)
|
# check download result and prepare list output (incl. tld compression, list backup & restore)
|
||||||
#
|
#
|
||||||
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpload}" ]
|
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpload}" ]
|
||||||
then
|
then
|
||||||
awk "${src_rset}" "${adb_tmpload}" 2>/dev/null > "${adb_tmpfile}"
|
awk "${src_rset}" "${adb_tmpload}" 2>/dev/null > "${adb_tmpfile}"
|
||||||
if [ -s "${adb_tmpfile}" ]
|
if [ -s "${adb_tmpfile}" ]
|
||||||
then
|
then
|
||||||
awk -F "." '{for(f=NF;f > 1;f--) printf "%s.", $f;print $1}' "${adb_tmpfile}" 2>/dev/null | sort -u > "${adb_tmpload}"
|
f_tldcompression "${adb_tmpfile}"
|
||||||
awk '{if(NR==1){tld=$NF};while(getline){if($NF !~ tld"\\."){print tld;tld=$NF}}print tld}' "${adb_tmpload}" 2>/dev/null > "${adb_tmpfile}"
|
|
||||||
awk -F "." '{for(f=NF;f > 1;f--) printf "%s.", $f;print $1}' "${adb_tmpfile}" 2>/dev/null > "${adb_tmpload}"
|
|
||||||
mv -f "${adb_tmpload}" "${adb_tmpfile}"
|
|
||||||
f_list backup
|
f_list backup
|
||||||
else
|
else
|
||||||
f_list restore
|
f_list restore
|
||||||
|
@ -521,11 +544,11 @@ f_main()
|
||||||
f_list restore
|
f_list restore
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove whitelist domains, final list preparation
|
# list merge
|
||||||
#
|
#
|
||||||
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ]
|
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ]
|
||||||
then
|
then
|
||||||
f_list format
|
f_list merge
|
||||||
if [ ${adb_rc} -ne 0 ]
|
if [ ${adb_rc} -ne 0 ]
|
||||||
then
|
then
|
||||||
f_list remove
|
f_list remove
|
||||||
|
@ -535,7 +558,7 @@ f_main()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# hash preparation and overall sort
|
# hash preparation, whitelist removal and overall sort
|
||||||
#
|
#
|
||||||
if [ -f "${adb_dnsdir}/${adb_dnsfile}" ]
|
if [ -f "${adb_dnsdir}/${adb_dnsfile}" ]
|
||||||
then
|
then
|
||||||
|
@ -545,10 +568,9 @@ f_main()
|
||||||
then
|
then
|
||||||
if [ ${mem_total} -ge 64 ] || [ ${adb_forcesrt} -eq 1 ]
|
if [ ${mem_total} -ge 64 ] || [ ${adb_forcesrt} -eq 1 ]
|
||||||
then
|
then
|
||||||
sort -u "${adb_tmpdir}/${adb_dnsfile}" > "${adb_dnsdir}/${adb_dnsfile}"
|
f_tldcompression "${adb_tmpdir}/${adb_dnsfile}"
|
||||||
else
|
|
||||||
mv -f "${adb_tmpdir}/${adb_dnsfile}" "${adb_dnsdir}" 2>/dev/null
|
|
||||||
fi
|
fi
|
||||||
|
f_list format
|
||||||
else
|
else
|
||||||
> "${adb_dnsdir}/${adb_dnsfile}"
|
> "${adb_dnsdir}/${adb_dnsfile}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue