mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-22 23:20:41 +08:00
DNS: generator: ip calculation in bash
This commit is contained in:
parent
91eff9f3ae
commit
9dce524994
2 changed files with 40 additions and 26 deletions
|
@ -107,22 +107,24 @@ $TTL 604800
|
||||||
142.0 IN PTR pan.icecat-jp3.tun30.neo.
|
142.0 IN PTR pan.icecat-jp3.tun30.neo.
|
||||||
|
|
||||||
; Point to Point Addresses
|
; Point to Point Addresses
|
||||||
1.10 IN PTR LanTian.pp.neo.
|
1.10 IN PTR LanTian.ptp.neo.
|
||||||
1.69 IN PTR santost12.pp.neo.
|
1.69 IN PTR santost12.ptp.neo.
|
||||||
2.127 IN PTR dfceaef.pp.neo.
|
1.69 IN PTR santost12.ptp.neo.
|
||||||
99.51 IN PTR JerryXiao.pp.neo.
|
2.127 IN PTR dfceaef.ptp.neo.
|
||||||
185.8 IN PTR staph.pp.neo.
|
99.51 IN PTR JerryXiao.ptp.neo.
|
||||||
193.8 IN PTR JerryXiao.pp.neo.
|
185.8 IN PTR staph.ptp.neo.
|
||||||
193.8 IN PTR JerryXiao.pp.neo.
|
193.8 IN PTR JerryXiao.ptp.neo.
|
||||||
193.8 IN PTR JerryXiao.pp.neo.
|
193.8 IN PTR JerryXiao.ptp.neo.
|
||||||
194.8 IN PTR JerryXiao-HK1.pp.neo.
|
193.8 IN PTR JerryXiao.ptp.neo.
|
||||||
194.8 IN PTR JerryXiao-HK1.pp.neo.
|
194.8 IN PTR JerryXiao-HK1.ptp.neo.
|
||||||
194.8 IN PTR JerryXiao-HK1.pp.neo.
|
194.8 IN PTR JerryXiao-HK1.ptp.neo.
|
||||||
195.8 IN PTR JerryXiao-SH1.pp.neo.
|
194.8 IN PTR JerryXiao-HK1.ptp.neo.
|
||||||
195.8 IN PTR JerryXiao-SH1.pp.neo.
|
195.8 IN PTR JerryXiao-SH1.ptp.neo.
|
||||||
196.8 IN PTR JerryXiao-HK2.pp.neo.
|
195.8 IN PTR JerryXiao-SH1.ptp.neo.
|
||||||
199.11 IN PTR SUNNET.pp.neo.
|
196.8 IN PTR JerryXiao-HK2.ptp.neo.
|
||||||
254.4 IN PTR Icecat-Explosion.pp.neo.
|
199.11 IN PTR SUNNET.ptp.neo.
|
||||||
|
253.4 IN PTR MagicNeko-JP3.ptp.neo.
|
||||||
|
254.4 IN PTR Icecat-Explosion.ptp.neo.
|
||||||
|
|
||||||
; Loopback Addresses
|
; Loopback Addresses
|
||||||
1.255 IN PTR NeoPDP-11.neo
|
1.255 IN PTR NeoPDP-11.neo
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
IPTOOL="$PWD/Misc/C/ip"
|
|
||||||
|
|
||||||
TUN30_TEMP="$(mktemp)"
|
TUN30_TEMP="$(mktemp)"
|
||||||
PP_TEMP="$(mktemp)"
|
PP_TEMP="$(mktemp)"
|
||||||
LO_TEMP="$(mktemp)"
|
LO_TEMP="$(mktemp)"
|
||||||
|
|
||||||
if [ ! -x "$IPTOOL" ]; then
|
if [[ "$(uname)" = *BSD ]]; then
|
||||||
echo "You need to build Misc/C/ip first"
|
TAC=gtac
|
||||||
exit 1
|
else
|
||||||
|
TAC=tac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_record()
|
print_record()
|
||||||
|
@ -17,6 +16,19 @@ print_record()
|
||||||
printf "%s\tIN\tPTR\t%s\n" "$1" "$2"
|
printf "%s\tIN\tPTR\t%s\n" "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcalc()
|
||||||
|
{
|
||||||
|
local subnet="$1"
|
||||||
|
local add="$2"
|
||||||
|
|
||||||
|
REV="$(echo -n "${subnet%,*}." | "$TAC" -s .)"
|
||||||
|
REV="${REV%.*.*.}"
|
||||||
|
|
||||||
|
echo "$[ ${REV%.*} + $add ].${REV#*.}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# PROGRAM BEGIN
|
||||||
|
|
||||||
sed -i '/AUTOGENERATED/,$d' dns/db.10.127
|
sed -i '/AUTOGENERATED/,$d' dns/db.10.127
|
||||||
echo '; AUTOGENERATED' >> dns/db.10.127
|
echo '; AUTOGENERATED' >> dns/db.10.127
|
||||||
|
|
||||||
|
@ -25,8 +37,8 @@ cd route
|
||||||
for i in *; do
|
for i in *; do
|
||||||
source "$i"
|
source "$i"
|
||||||
if [ "$TYPE" = "TUN30" ]; then
|
if [ "$TYPE" = "TUN30" ]; then
|
||||||
upstream_ip=$("$IPTOOL" "$i" 1)
|
upstream_ip=$(ipcalc "$i" 1)
|
||||||
downstream_ip=$("$IPTOOL" "$i" 2)
|
downstream_ip=$(ipcalc "$i" 2)
|
||||||
|
|
||||||
(
|
(
|
||||||
print_record "$upstream_ip" "$DOWNSTREAM.$UPSTREAM.tun30.neo."
|
print_record "$upstream_ip" "$DOWNSTREAM.$UPSTREAM.tun30.neo."
|
||||||
|
@ -38,13 +50,13 @@ for i in *; do
|
||||||
downstream_ip="${i#*~}"
|
downstream_ip="${i#*~}"
|
||||||
|
|
||||||
(
|
(
|
||||||
print_record "$("$IPTOOL" "$upstream_ip" 0)" "$UPSTREAM.ptp.neo."
|
print_record "$(ipcalc "$upstream_ip" 0)" "$UPSTREAM.ptp.neo."
|
||||||
print_record "$("$IPTOOL" "$downstream_ip" 0)" "$DOWNSTREAM.ptp.neo."
|
print_record "$(ipcalc "$downstream_ip" 0)" "$DOWNSTREAM.ptp.neo."
|
||||||
) >> "$PP_TEMP"
|
) >> "$PP_TEMP"
|
||||||
elif [ "$TYPE" = "LO" ]; then
|
elif [ "$TYPE" = "LO" ]; then
|
||||||
ip="${i/,32/}"
|
ip="${i/,32/}"
|
||||||
|
|
||||||
print_record "$("$IPTOOL" "$ip" 0)" "$NAME.neo" >> "$LO_TEMP"
|
print_record "$(ipcalc "$ip" 0)" "$NAME.neo" >> "$LO_TEMP"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue