As arokh suggested, I took his latest source and built image for my TL-WDR4300 based on 3x00. As this router only has 8MB flash, I had to "loose" a few packages. I chose to remove tor, miniupnpd and unfs3. Also, the original image packs default hosts adblock list which makes image 130k larger. Since I spent a few days tuning different settings and reading through all the posts of this thread (yes really) I wanted to make a few suggestions for improvements.
1. netlink: 11 bytes leftover after parsing attributes in process `ip'.
In my logs I noticed this message and found ticket created by a friend of this build @hnyman: https://dev.openwrt.org/ticket/20470
I was able to make the message disappear by disabling building of IP applets (CONFIG_BUSYBOX_CONFIG_IP, CONFIG_BUSYBOX_CONFIG_FEATURE_IP_*) in BusyBox which is anyway not needed since this build includes PACKAGE_ip required by SQM.
The ticket also discovered strange behaviour of $PATH variable changing from "/bin:/sbin:/usr/bin:/usr/sbin" to "/usr/bin:/usr/sbin:/bin:/sbin", which might have much bigger impact on all startup/init scripts and is something you will need to consider in your builds.
2. improved adblock.sh
To further squeeze the build I removed the "bad hosts" list included in the build which shaved off 130k of data. As users need to be able to tune this file due to increasing use of anti-adblock scripts I think it is better to dynamically build the bad hosts list in the /tmp folder (where there is enough space). Below are the changes I made to arokh's adblock.sh script which combines downloading part from his build.sh and creates the file in /tmp/hosts folder instead. The /tmp/hosts folder is being automatically created and configured by /etc/init.d/dnsmasq. As an added bonus you can add a cron job to update this list at a desired frequency.
Drop-in replacement for: /usr/sbin/adblock.sh
#!/bin/sh
# Check your firewall prerouting_rule for correct IP
PIXELSERV_IP="192.168.3.254"
# Domains to exclude from blocking, ie. ads.hulu.com
WHITELIST_DOMAINS="ads.hulu.com cdn.optimizely.com"
# Hosts files will be downloaded from following sources
ADBLOCK_HOSTS="\
http://www.mvps.org/winhelp2002/hosts.txt \
http://www.malwaredomainlist.com/hostslist/hosts.txt \
http://hosts-file.net/.\ad_servers.txt \
http://sysctl.org/cameleon/hosts.win \
http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext \
http://adaway.org/hosts.txt"
H_TMP=/tmp/hosts.tmp
H=/tmp/hosts/hosts.bad
DM=/etc/init.d/dnsmasq
download_hosts() {
rm -f $H_TMP
for hosts_file in $ADBLOCK_HOSTS; do
wget -qO- $hosts_file >> $H_TMP
done
# Explicitly remove following domains from adblock file
for wd in $WHITELIST_DOMAINS; do
sed -i "/$wd/d" $H_TMP
done
sed -i '/localhost/d;s/^0\.0\.0\.0.//;s/^127\.0\.0\.1.//;s/[[:cntrl:]]$//;s/[[:cntrl:]]$/ /;/^#/d;/^$/d;s/[[:space:]]*#.*$//;s/^ //;s/^ //;s|^|'$PIXELSERV_IP' |' $H_TMP
rm -f $H
sort $H_TMP|uniq > $H
rm -f $H_TMP
}
case "$1" in
refresh)
# download latest hosts
echo "Downloading list of bad hosts"
download_hosts
;;
enable)
mkdir -p /tmp/hosts
#uci -q show dhcp.@dnsmasq[0].addnhosts > /dev/null && exit 0
[ ! -f $H ] && $0 refresh
#uci add_list dhcp.@dnsmasq[0].addnhosts='/etc/hosts.block'
#uci commit
echo "Adblocking enabled..."
;;
disable)
[ -f $H ] && rm -f $H
#uci -q show dhcp.@dnsmasq[0].addnhosts > /dev/null || exit 0
#uci -q delete dhcp.@dnsmasq[0].addnhosts
#uci commit
echo "Adblocking disabled..."
;;
*)
echo "Usage: $0 [ enable | disable | refresh ]"
exit 0
;;
esac
$DM restart
Thank you again for all the hard work!