mirror of
https://github.com/gaoyifan/china-operator-ip.git
synced 2025-07-14 13:22:27 +08:00
Support parallel generating
This commit is contained in:
parent
da40357727
commit
a497a9fc47
19
common.sh
19
common.sh
@ -19,15 +19,24 @@ get_asn(){
|
|||||||
awk '{gsub(/AS/, ""); print $1 }'
|
awk '{gsub(/AS/, ""); print $1 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_data(){
|
prepare_data_v4(){
|
||||||
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt
|
|
||||||
curl -sSLo rib.bz2 http://archive.routeviews.org/dnszones/rib.bz2
|
curl -sSLo rib.bz2 http://archive.routeviews.org/dnszones/rib.bz2
|
||||||
|
log_info "runing bgpdump v4 ..."
|
||||||
|
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib.txt rib.bz2
|
||||||
|
log_info "finish bgpdump v4"
|
||||||
|
}
|
||||||
|
prepare_data_v6(){
|
||||||
IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata"
|
IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata"
|
||||||
MONTH6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM 2>/dev/null | sort | tail -n 1)
|
MONTH6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM 2>/dev/null | sort | tail -n 1)
|
||||||
LATEST6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM/$MONTH6/RIBS/ 2>/dev/null | sort | tail -n 1)
|
LATEST6=$(lftp -e 'cls -1;exit' $IP6UPSTREAM/$MONTH6/RIBS/ 2>/dev/null | sort | tail -n 1)
|
||||||
curl -sSLo rib6.bz2 "$IP6UPSTREAM/$MONTH6/RIBS/$LATEST6"
|
curl -sSLo rib6.bz2 "$IP6UPSTREAM/$MONTH6/RIBS/$LATEST6"
|
||||||
log_info "runing bgpdump ..."
|
log_info "runing bgpdump v6 ..."
|
||||||
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib.txt rib.bz2
|
|
||||||
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib6.txt rib6.bz2
|
docker run -it --rm -v `pwd`:/bgpdump -w /bgpdump gaoyifan/bgpdump bgpdump -m -O rib6.txt rib6.bz2
|
||||||
log_info "done"
|
log_info "finish bgpdump v6"
|
||||||
|
}
|
||||||
|
prepare_data(){
|
||||||
|
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt &
|
||||||
|
prepare_data_v4 &
|
||||||
|
prepare_data_v6 &
|
||||||
|
wait
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,15 @@
|
|||||||
source common.sh
|
source common.sh
|
||||||
set -e
|
set -e
|
||||||
[[ $SKIP_DATA_PREPARATION != true ]] && prepare_data
|
[[ $SKIP_DATA_PREPARATION != true ]] && prepare_data
|
||||||
|
reset
|
||||||
mkdir -p result
|
mkdir -p result
|
||||||
for file in operator/*.conf; do
|
for file in operator/*.conf; do
|
||||||
operator=${file%.*}
|
operator=${file%.*}
|
||||||
operator=${operator##*/}
|
operator=${operator##*/}
|
||||||
log_info "generating IP list of $operator ..."
|
log_info "generating IP list of $operator ..."
|
||||||
get_asn $file
|
get_asn $file
|
||||||
get_asn $file | xargs bgptools -b rib.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}.txt
|
get_asn $file | xargs bgptools -b rib.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}.txt &
|
||||||
get_asn $file | xargs bgptools -b rib6.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}6.txt
|
get_asn $file | xargs bgptools -b rib6.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}6.txt &
|
||||||
done
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
Loading…
Reference in New Issue
Block a user