瀏覽代碼

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.
Matteo Croce 9 年之前
父節點
當前提交
5b8d596ab9
共有 2 個文件被更改,包括 59 次插入0 次删除
  1. 40
    0
      utils/banhosts/Makefile
  2. 19
    0
      utils/banhosts/files/updatebanhost

+ 40
- 0
utils/banhosts/Makefile 查看文件

@@ -0,0 +1,40 @@
1
+#
2
+# Copyright (C) 2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=banhostlist
11
+PKG_VERSION:=1
12
+PKG_RELEASE:=1
13
+
14
+PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
15
+PKG_MAINTAINER:=Matteo Croce <matteo@openwrt.org>
16
+PKG_LICENCE:=GPL-2.0
17
+
18
+include $(INCLUDE_DIR)/package.mk
19
+
20
+define Package/banhostlist
21
+  SECTION:=utils
22
+  CATEGORY:=Utilities
23
+  TITLE:=List of advertising domains
24
+  URL:=http://winhelp2002.mvps.org/
25
+endef
26
+
27
+define Package/banhostlist/description
28
+List of domains serving advertising and malicious content to easily block them
29
+endef
30
+
31
+
32
+define Build/Compile/Default
33
+endef
34
+
35
+define Package/banhostlist/install
36
+	$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
37
+	$(INSTALL_BIN) ./files/updatebanhost $(1)/etc/hotplug.d/iface/80-banhosts
38
+endef
39
+
40
+$(eval $(call BuildPackage,banhostlist))

+ 19
- 0
utils/banhosts/files/updatebanhost 查看文件

@@ -0,0 +1,19 @@
1
+#!/bin/sh
2
+
3
+file=/tmp/banhost
4
+
5
+gethosts() {
6
+	logger -t "banhost[$$]" "Update $file"
7
+	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
8
+	echo -n $time >$file.time
9
+	exec killall -HUP dnsmasq
10
+}
11
+
12
+if [ "$ACTION" = ifup -a "$INTERFACE" = wan ]; then
13
+	read time </proc/uptime
14
+	time=${time%%.*}
15
+
16
+	[ -f $file -a -f $file.time ] || gethosts
17
+	read oldtime <$file.time
18
+	[ $((time - oldtime)) -lt 604800 ] || gethosts
19
+fi