thebigfing
New Around Here
Out of curiosity.
#!/bin/sh
logmsg() {
logger -t "$(basename $0)" "$@"
[ -t 1 ] && printf "%s\n" "$@"
}
logmsg "Starting adblock update"
[ -d /opt/share/oisd ] || mkdir -p /opt/share/oisd
[ -f /opt/share/oisd/whitelist ] || touch /opt/share/oisd/whitelist
cd /opt/share/oisd || exit 1
# Only download the file if it is newer on the server, or missing locally
if ! wget -N -q https://small.oisd.nl/dnsmasq2; then
logmsg "oisd.nl download failed!"
exit 1
fi
# Exit if the downloaded file is still older than the current local blocklist
if [ -f /opt/share/oisd/oisd.list ]; then
if [ /opt/share/oisd/dnsmasq2 -ot /opt/share/oisd/oisd.list ]; then
logmsg "No change in remote oisd list"
exit
fi
fi
# Reformat the list with address= commands and remove whitelist entries
if [ -f /opt/share/oisd/dnsmasq2 ]; then
/bin/grep -E "^local=/[A-Za-z0-9._-]+/$" /opt/share/oisd/dnsmasq2 | \
/bin/grep -E -v -i -f /opt/share/oisd/whitelist | \
awk -F/ ' { printf "address=/%s/#\nlocal=/%s/\n", $2, $2 } ' > /tmp/oisd.new
else
logmsg "No blocklist found after download!"
exit 1
fi
# Test if dnsmasq has any problems with the new blocklist before promoting it to the live blocklist
if dnsmasq --test --conf-file=/tmp/oisd.new >/dev/null 2>&1; then
logmsg "Restarting dnsmasq with updated blocking list"
mv /tmp/oisd.new /opt/share/oisd/oisd.list
service restart_dnsmasq
else
logmsg "dnsmasq did not like the new file"
exit 1
fi
[ -s /opt/share/oisd/oisd.list ] && pc_append "conf-file=/opt/share/oisd/oisd.list" "$CONFIG"
Uh nice, on my way to the US for work and did not bring along a router to test this on.I normally would have run Diversion, but wanted to solve the iOS HTTPS (Type65) query problem, so I adapted a custom script for using a modified version of a list from oisd.nl.
In /jffs/scripts/dnsmasq.postconf:Bash:#!/bin/sh logmsg() { logger -t "$(basename $0)" "$@" [ -t 1 ] && printf "%s\n" "$@" } logmsg "Starting adblock update" [ -d /opt/share/oisd ] || mkdir -p /opt/share/oisd [ -f /opt/share/oisd/whitelist ] || touch /opt/share/oisd/whitelist cd /opt/share/oisd || exit 1 # Only download the file if it is newer on the server, or missing locally if ! wget -N -q https://small.oisd.nl/dnsmasq2; then logmsg "oisd.nl download failed!" exit 1 fi # Exit if the downloaded file is still older than the current local blocklist if [ -f /opt/share/oisd/oisd.list ]; then if [ /opt/share/oisd/dnsmasq2 -ot /opt/share/oisd/oisd.list ]; then logmsg "No change in remote oisd list" exit fi fi # Reformat the list with address= commands and remove whitelist entries if [ -f /opt/share/oisd/dnsmasq2 ]; then /bin/grep -E "^local=/[A-Za-z0-9._-]+/$" /opt/share/oisd/dnsmasq2 | \ /bin/grep -E -v -i -f /opt/share/oisd/whitelist | \ awk -F/ ' { printf "address=/%s/#\nlocal=/%s/\n", $2, $2 } ' > /tmp/oisd.new else logmsg "No blocklist found after download!" exit 1 fi # Test if dnsmasq has any problems with the new blocklist before promoting it to the live blocklist if dnsmasq --test --conf-file=/tmp/oisd.new >/dev/null 2>&1; then logmsg "Restarting dnsmasq with updated blocking list" mv /tmp/oisd.new /opt/share/oisd/oisd.list service restart_dnsmasq else logmsg "dnsmasq did not like the new file" exit 1 fi
Bash:[ -s /opt/share/oisd/oisd.list ] && pc_append "conf-file=/opt/share/oisd/oisd.list" "$CONFIG"
Sigh…..@Phil Mcavity
There once was a young Dr dentist named Malone
Who got a pretty young patient alone
And in his depravity
He filled the wrong cavity
And my how his practice has grown
Sigh…..
I wondered how long it would take!
@thelonelycoderUh nice, on my way to the US for work and did not bring along a router to test this on.
You‘re saying this works means it will be a feature for Diversion.
Thanks mate.
It was implemented some time ago, the Type 65 option. look in the GUI tab@thelonelycoder
Sorry to bug you and i just ran into this by chance but Just curious if this feature will be implemented in the new Diversion update?
It's the reason why it takes so long for this update. It affects much much more than just the few lines of (excellent) code by @dave14305 to bring Diversion up to speed.@thelonelycoder
Sorry to bug you and i just ran into this by chance but Just curious if this feature will be implemented in the new Diversion update?
I concur. You don't want to do Diversion a disservice by replacing it with such elegantly simple code. Diversion must maintain its standard that you have granularly developed over its life cycle. I think we all can appreciate that.It's the reason why it takes so long for this update. It affects much much more than just the few lines of (excellent) code by @dave14305 to bring Diversion up to speed.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!