aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMatteo Croce <matteo@openwrt.org>2015-07-02 21:58:16 +0200
committerMatteo Croce <matteo@openwrt.org>2015-07-03 12:21:03 +0200
commit5b8d596ab9df3a7bd86892e7206a18f67d61e43e (patch)
tree93b9348559940001136e620e64f1753e85046ad9 /utils
parentb59187dc627efbf1f779d5789ab653adc16b8697 (diff)
add list of domains serving advertising
Add a script to download a list of domains which serves ads. This list can be used to block these servers in the DNS server.
Diffstat (limited to 'utils')
-rw-r--r--utils/banhosts/Makefile40
-rw-r--r--utils/banhosts/files/updatebanhost19
2 files changed, 59 insertions, 0 deletions
diff --git a/utils/banhosts/Makefile b/utils/banhosts/Makefile
new file mode 100644
index 000000000..0087a6ff1
--- /dev/null
+++ b/utils/banhosts/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=banhostlist
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_MAINTAINER:=Matteo Croce <matteo@openwrt.org>
+PKG_LICENCE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/banhostlist
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=List of advertising domains
+ URL:=http://winhelp2002.mvps.org/
+endef
+
+define Package/banhostlist/description
+List of domains serving advertising and malicious content to easily block them
+endef
+
+
+define Build/Compile/Default
+endef
+
+define Package/banhostlist/install
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_BIN) ./files/updatebanhost $(1)/etc/hotplug.d/iface/80-banhosts
+endef
+
+$(eval $(call BuildPackage,banhostlist))
diff --git a/utils/banhosts/files/updatebanhost b/utils/banhosts/files/updatebanhost
new file mode 100644
index 000000000..a00d9cb6b
--- /dev/null
+++ b/utils/banhosts/files/updatebanhost
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+file=/tmp/banhost
+
+gethosts() {
+ logger -t "banhost[$$]" "Update $file"
+ wget -qO- http://winhelp2002.mvps.org/hosts.txt |awk 'BEGIN{printf "0.0.0.0"}/^0\.0\.0\.0/{printf " "$2}END{exit(!FNR)}' >$file || exit 1
+ echo -n $time >$file.time
+ exec killall -HUP dnsmasq
+}
+
+if [ "$ACTION" = ifup -a "$INTERFACE" = wan ]; then
+ read time </proc/uptime
+ time=${time%%.*}
+
+ [ -f $file -a -f $file.time ] || gethosts
+ read oldtime <$file.time
+ [ $((time - oldtime)) -lt 604800 ] || gethosts
+fi