From 66a890ef5c206a641b26ac300917e7341cc93a1a Mon Sep 17 00:00:00 2001 From: Neo_Chen Date: Sat, 2 May 2020 16:11:11 +0800 Subject: [PATCH] scripts: Added roa.sh --- scripts/roa.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/roa.sh diff --git a/scripts/roa.sh b/scripts/roa.sh new file mode 100755 index 0000000..5e4997b --- /dev/null +++ b/scripts/roa.sh @@ -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 +)