diff --git a/Makefile b/Makefile index f72f051..f5ee3c8 100755 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/resources/alt-formats/rpz.sh b/resources/alt-formats/rpz.sh new file mode 100755 index 0000000..5efae0e --- /dev/null +++ b/resources/alt-formats/rpz.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Author: Héctor Molinero Fernández +# 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>/!d;/^\s*#.*$/d' \ + -e 's/^\(.\{1,\}\)\s\{1,\}\(.\{1,\}\)\s*/\2 CNAME ./p' \ + "$hosts" +} + +main "$@"