1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-06-29 18:38:40 +08:00
NeoNetwork/scripts/dns-reverse-generator.sh

39 lines
790 B
Bash
Raw Normal View History

2020-04-26 11:10:48 +08:00
#!/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)
2020-04-26 12:20:06 +08:00
print_record "$upstream_ip" "$DOWNSTREAM.$UPSTREAM.tun30.neo."
print_record "$downstream_ip" "$UPSTREAM.$DOWNSTREAM.tun30.neo."
elif [ "$TYPE" = "PP" ]; then
i="${i/PP,/}"
upstream_ip="${i%~*}"
downstream_ip="${i#*~}"
print_record "$upstream_ip" "$UPSTREAM.pp.neo."
print_record "$downstream_ip" "$DOWNSTREAM.pp.neo."
2020-04-26 11:10:48 +08:00
fi
done
) | sort -n >> dns/db.10.127