Added DNS Response Policy Zone (RPZ) format

This commit is contained in:
Héctor Molinero Fernández 2018-06-11 23:12:50 +02:00
commit c57109002a
2 changed files with 50 additions and 3 deletions

View file

@ -25,14 +25,32 @@ export DEFAULT_HOSTS
.PHONY: all \
install uninstall \
build build-hosts build-domains build-adblock build-dnsmasq build-unbound build-android build-windows \
stats stats-tlds stats-suffixes \
build \
build-hosts \
build-domains \
build-adblock \
build-rpz \
build-dnsmasq \
build-unbound \
build-android \
build-windows \
stats \
stats-tlds \
stats-suffixes \
index \
clean
all: build index
build: build-hosts build-domains build-adblock build-dnsmasq build-unbound build-android build-windows
build: \
build-hosts \
build-domains \
build-adblock \
build-rpz \
build-dnsmasq \
build-unbound \
build-android \
build-windows
build-hosts: dist/hosts
dist/hosts:
@ -47,6 +65,10 @@ build-adblock: build-hosts dist/hosts_adblock.txt
dist/hosts_adblock.txt:
"$(MKFILE_DIR)"/resources/alt-formats/adblock.sh dist/hosts > dist/hosts_adblock.txt
build-rpz: build-hosts dist/hosts_rpz.txt
dist/hosts_rpz.txt:
"$(MKFILE_DIR)"/resources/alt-formats/rpz.sh dist/hosts > dist/hosts_rpz.txt
build-dnsmasq: build-hosts dist/hosts_dnsmasq.conf
dist/hosts_dnsmasq.conf:
"$(MKFILE_DIR)"/resources/alt-formats/dnsmasq.sh dist/hosts > dist/hosts_dnsmasq.conf
@ -108,6 +130,7 @@ clean:
dist/hosts \
dist/hosts_domains.txt \
dist/hosts_adblock.txt \
dist/hosts_rpz.txt \
dist/hosts_dnsmasq.conf \
dist/hosts_unbound.conf \
dist/hosts_android.zip \

24
resources/alt-formats/rpz.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
# Author: Héctor Molinero Fernández <hector@molinero.xyz>
# Repository: https://github.com/hectorm/hblock
# License: MIT, https://opensource.org/licenses/MIT
set -eu
export LC_ALL=C
main() {
hosts="${1:?}"
cat <<-'EOF'
$TTL 2h
@ IN SOA localhost. root.localhost. (1 6h 1h 1w 2h)
IN NS localhost.
EOF
sed -n \
-e '/^#.*<blocklist>/,/^#.*<\/blocklist>/!d;/^\s*#.*$/d' \
-e 's/^\(.\{1,\}\)\s\{1,\}\(.\{1,\}\)\s*/\2 CNAME ./p' \
"$hosts"
}
main "$@"