diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0bdf2962 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/asnames.txt +/rib.txt +/rib.bz2 +/result diff --git a/generate.sh b/generate.sh new file mode 100755 index 00000000..de159018 --- /dev/null +++ b/generate.sh @@ -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 diff --git a/operator/cernet.conf b/operator/cernet.conf new file mode 100644 index 00000000..4d1dbb6c --- /dev/null +++ b/operator/cernet.conf @@ -0,0 +1,2 @@ +PATTERN='cernet' +COUNTRY='CN' diff --git a/operator/chinnet.conf b/operator/chinnet.conf new file mode 100644 index 00000000..f38934fd --- /dev/null +++ b/operator/chinnet.conf @@ -0,0 +1,2 @@ +PATTERN='(china ?telecom|chinanet)' +COUNTRY='CN' diff --git a/operator/cmcc.conf b/operator/cmcc.conf new file mode 100644 index 00000000..f37cdc31 --- /dev/null +++ b/operator/cmcc.conf @@ -0,0 +1,2 @@ +PATTERN='mobile' +COUNTRY='CN' diff --git a/operator/cstnet.conf b/operator/cstnet.conf new file mode 100644 index 00000000..efda1363 --- /dev/null +++ b/operator/cstnet.conf @@ -0,0 +1,2 @@ +PATTERN='cstnet' +COUNTRY='CN' diff --git a/operator/tietong.conf b/operator/tietong.conf new file mode 100644 index 00000000..722309a3 --- /dev/null +++ b/operator/tietong.conf @@ -0,0 +1,2 @@ +PATTERN='tietong' +COUNTRY='CN' diff --git a/operator/unicom.conf b/operator/unicom.conf new file mode 100644 index 00000000..51ff0a99 --- /dev/null +++ b/operator/unicom.conf @@ -0,0 +1,2 @@ +PATTERN='unicom' +COUNTRY='CN'