blackholedns (698B)
1 #!/bin/dash 2 # 3 # gets list to blackhole from http://someonewhocares.org/hosts/hosts 4 # 5 # example cronjob: every day at 15:33 6 # 33 15 * * * /path/to/blackholedns > /etc/unbound/blackhole.dns 7 # unbound: 8 # include: "/etc/unbound/blackhole.dns" 9 10 [ -n "$TORIFY" ] && proxy="--proxy socks5://127.0.0.1:9050" 11 12 urls="$(curl -s ${proxy} http://someonewhocares.org/hosts/hosts)" 13 14 [ -n "$urls" ] || exit 1 15 16 tmpfile="$(mktemp)" 17 18 printf "%s\n" "$urls" | grep -e '^127' | mawk '{print $2}'| tail -n+7 > $tmpfile 19 20 while read line; do 21 printf "%s" "$line" \ 22 | grep -E '+([a-z]|[A-Z]|['.'])' \ 23 | sed 's/.*/local-zone: "&" redirect,local-data: "& A 127.0.0.1"/' \ 24 | tr ',' '\n' 25 done < "$tmpfile" 26 27 rm -f "$tmpfile"