From 69e72e68b75ec3adcf049c49405df6e8fb778a2d Mon Sep 17 00:00:00 2001 From: Neo_Chen Date: Sun, 26 Apr 2020 11:10:48 +0800 Subject: [PATCH] DNS: reverse record generator --- Misc | 2 +- scripts/dns-reverse-generator.sh | 31 +++++++++++++++++++ .../homepage-update.sh | 0 makegraph.sh => scripts/makegraph.sh | 0 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 scripts/dns-reverse-generator.sh rename homepage-update.sh => scripts/homepage-update.sh (100%) rename makegraph.sh => scripts/makegraph.sh (100%) diff --git a/Misc b/Misc index 9a58f95..b2c08da 160000 --- a/Misc +++ b/Misc @@ -1 +1 @@ -Subproject commit 9a58f95630a22678cd9a02a6fcc5d1e54d2bff3a +Subproject commit b2c08da8438078fd7f8ac167b57dcd57b6f0f9c6 diff --git a/scripts/dns-reverse-generator.sh b/scripts/dns-reverse-generator.sh new file mode 100755 index 0000000..a9c025d --- /dev/null +++ b/scripts/dns-reverse-generator.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -e + +IPTOOL="$PWD/Misc/C/ip" + +if [ ! -x "$IPTOOL" ]; then + echo "You need to build Misc/C/ip first" + exit 1 +fi + +print_record() +{ + printf "%s\tIN\tPTR\t%s\n" "$1" "$2" +} + +sed -i '/AUTOGENERATED/,$d' dns/db.10.127 +echo '; AUTOGENERATED' >> dns/db.10.127 + +( +cd route +for i in *; do + source "$i" + if [ "$TYPE" = "TUN30" ]; then + upstream_ip=$("$IPTOOL" "$i" 1) + downstream_ip=$("$IPTOOL" "$i" 2) + + print_record "$upstream_ip" "$UPSTREAM" + print_record "$downstream_ip" "$DOWNSTREAM" + fi +done +) | sort -n >> dns/db.10.127 diff --git a/homepage-update.sh b/scripts/homepage-update.sh similarity index 100% rename from homepage-update.sh rename to scripts/homepage-update.sh diff --git a/makegraph.sh b/scripts/makegraph.sh similarity index 100% rename from makegraph.sh rename to scripts/makegraph.sh