adapt bgptools 0.0.1

This commit is contained in:
Yifan Gao 2017-01-21 23:25:52 +08:00
parent efbdcedff8
commit a727caa71f
8 changed files with 55 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/asnames.txt
/rib.txt
/rib.bz2
/result

39
generate.sh Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
if [[ -f /etc/kern_loader.conf ]]; then
alias grep='ggrep'
fi
get_asn(){
CONF_FILE=$1
unset PATTERN
unset COUNTRY
source $CONF_FILE
grep -P "${COUNTRY}\$" asnames.txt |
grep -Pi $PATTERN |
awk '{print $1}' |
while read ASN; do
ASN=${ASN#AS}
if grep '\.' <(echo $ASN) > /dev/null; then
ASN_HIGH=${ASN%.*}
ASN_LOW=${ASN#*.}
ASN=$((ASN_HIGH * 65536 + ASN_LOW))
fi
echo $ASN
done
}
prepare_data(){
wget http://bgp.potaroo.net/as1221/asnames.txt
wget http://archive.routeviews.org/dnszones/rib.bz2
bgpdump -m -O rib.txt rib.bz2
}
set -e
[[ $DEBUG != true ]] && prepare_data
mkdir -p result
find operator -type f -name '*.conf' |
while read file; do
operator=${file%.*}
operator=${operator##*/}
get_asn $file | xargs bgptools | uniq > result/$operator.txt
done

2
operator/cernet.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='cernet'
COUNTRY='CN'

2
operator/chinnet.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='(china ?telecom|chinanet)'
COUNTRY='CN'

2
operator/cmcc.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='mobile'
COUNTRY='CN'

2
operator/cstnet.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='cstnet'
COUNTRY='CN'

2
operator/tietong.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='tietong'
COUNTRY='CN'

2
operator/unicom.conf Normal file
View File

@ -0,0 +1,2 @@
PATTERN='unicom'
COUNTRY='CN'