mirror of
https://github.com/gaoyifan/china-operator-ip.git
synced 2025-07-13 21:02:37 +08:00
adapt bgptools 0.0.1
This commit is contained in:
parent
efbdcedff8
commit
a727caa71f
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/asnames.txt
|
||||
/rib.txt
|
||||
/rib.bz2
|
||||
/result
|
39
generate.sh
Executable file
39
generate.sh
Executable 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
2
operator/cernet.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='cernet'
|
||||
COUNTRY='CN'
|
2
operator/chinnet.conf
Normal file
2
operator/chinnet.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='(china ?telecom|chinanet)'
|
||||
COUNTRY='CN'
|
2
operator/cmcc.conf
Normal file
2
operator/cmcc.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='mobile'
|
||||
COUNTRY='CN'
|
2
operator/cstnet.conf
Normal file
2
operator/cstnet.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='cstnet'
|
||||
COUNTRY='CN'
|
2
operator/tietong.conf
Normal file
2
operator/tietong.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='tietong'
|
||||
COUNTRY='CN'
|
2
operator/unicom.conf
Normal file
2
operator/unicom.conf
Normal file
@ -0,0 +1,2 @@
|
||||
PATTERN='unicom'
|
||||
COUNTRY='CN'
|
Loading…
Reference in New Issue
Block a user