1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-12-25 13:49:23 +08:00

scripts: Added roa.sh

This commit is contained in:
Neo_Chen 2020-05-02 16:11:11 +08:00
parent b906c3dd51
commit 66a890ef5c

33
scripts/roa.sh Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e
INET4PFXLEN="29"
INET6PFXLEN="64"
print_record()
{
printf "route %s max %d as %u;\n" "$1" "$2" "$3"
}
# PROGRAM BEGIN
echo "# NeoNetwork ROA Tool"
(
for i in route*/* ; do
source "$i"
if [ "$TYPE" != PTP ]; then
prefix="${i#route*/}"
prefix="${prefix/,/\/}"
pfxlen="${i#*,}"
if [ "$TYPE" = "SUBNET" ]; then
if [ "$pfxlen" -le "$INET4PFXLEN" ]||[ "$pfxlen" -ge 32 ]&&[ "$pfxlen" -le "$INET6PFXLEN" ]; then
print_record "$prefix" "$INET4PFXLEN" "$ASN"
fi
elif [ "$TYPE" = "LO" ]; then
print_record "$prefix" 32 "$ASN"
fi
fi
done
)