mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-25 22:40:41 +08:00
61 lines
1.2 KiB
Bash
Executable file
61 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
IPTOOL="$PWD/Misc/C/ip"
|
|
|
|
TUN30_TEMP="$(mktemp)"
|
|
PP_TEMP="$(mktemp)"
|
|
LO_TEMP="$(mktemp)"
|
|
|
|
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" "$DOWNSTREAM.$UPSTREAM.tun30.neo."
|
|
print_record "$downstream_ip" "$UPSTREAM.$DOWNSTREAM.tun30.neo."
|
|
) >> "$TUN30_TEMP"
|
|
elif [ "$TYPE" = "PP" ]; then
|
|
i="${i/PP,/}"
|
|
upstream_ip="${i%~*}"
|
|
downstream_ip="${i#*~}"
|
|
|
|
(
|
|
print_record "$("$IPTOOL" "$upstream_ip" 0)" "$UPSTREAM.ptp.neo."
|
|
print_record "$("$IPTOOL" "$downstream_ip" 0)" "$DOWNSTREAM.ptp.neo."
|
|
) >> "$PP_TEMP"
|
|
elif [ "$TYPE" = "LO" ]; then
|
|
ip="${i/,32/}"
|
|
|
|
print_record "$("$IPTOOL" "$ip" 0)" "$NAME.neo" >> "$LO_TEMP"
|
|
fi
|
|
done
|
|
)
|
|
|
|
{
|
|
echo -e "\n; Tunnel /30 Addresses"
|
|
sort -n < "$TUN30_TEMP"
|
|
echo -e "\n; Point to Point Addresses"
|
|
sort -n < "$PP_TEMP"
|
|
echo -e "\n; Loopback Addresses"
|
|
sort -n < "$LO_TEMP"
|
|
} >> dns/db.10.127
|
|
|
|
rm -f "$TUN30_TEMP" "$PP_TEMP" "$LO_TEMP"
|