diff --git a/.travis.yml b/.travis.yml index 4caf6ace..f4d8f878 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ sudo: required +dist: bionic +addons: + apt: + packages: + - lftp services: - docker language: rust env: global: - - BGPTOOLS_VERSION=0.0.1 + - BGPTOOLS_VERSION=0.0.2 before_script: - cargo install --vers $BGPTOOLS_VERSION bgptools - export PATH=$PATH:/home/travis/.cargo/bin - - docker pull gaoyifan/cidrmerge + - docker pull yangzhaofengsteven/cidr-merge - docker pull gaoyifan/bgpdump script: - ./generate.sh diff --git a/common.sh b/common.sh index 394b26ea..f357d6b8 100755 --- a/common.sh +++ b/common.sh @@ -20,9 +20,14 @@ get_asn(){ } prepare_data(){ - curl -sSLo asnames.txt http://bgp.potaroo.net/as1221/asnames.txt + 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 + IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata" + 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) + curl -sSLo rib6.bz2 "$IP6UPSTREAM/$MONTH6/RIBS/$LATEST6" log_info "runing bgpdump ..." 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 log_info "done" } diff --git a/generate.sh b/generate.sh index c752413e..5ba4c845 100755 --- a/generate.sh +++ b/generate.sh @@ -8,6 +8,14 @@ for file in operator/*.conf; do operator=${file%.*} operator=${operator##*/} log_info "generating IP list of $operator ..." - get_asn $file | tee /dev/stderr | xargs bgptools | docker run -i --rm gaoyifan/cidrmerge > result/$operator.txt + get_asn $file | tee /dev/stderr | xargs bgptools -b rib.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/$operator.txt + log_info "done" +done + +for file in operator6/*.conf; do + operator=${file%.*} + operator=${operator##*/} + log_info "generating IPv6 list of $operator ..." + get_asn $file | tee /dev/stderr | xargs bgptools -b rib6.txt | sort | uniq | docker run -i --rm yangzhaofengsteven/cidr-merge > result/${operator}6.txt log_info "done" done diff --git a/operator6/cernet.conf b/operator6/cernet.conf new file mode 100644 index 00000000..f6fbd173 --- /dev/null +++ b/operator6/cernet.conf @@ -0,0 +1,2 @@ +PATTERN='(cngi|cernet)' +COUNTRY='CN' diff --git a/operator6/china.conf b/operator6/china.conf new file mode 120000 index 00000000..be88440d --- /dev/null +++ b/operator6/china.conf @@ -0,0 +1 @@ +../operator/china.conf \ No newline at end of file diff --git a/operator6/chinanet.conf b/operator6/chinanet.conf new file mode 120000 index 00000000..868d70fd --- /dev/null +++ b/operator6/chinanet.conf @@ -0,0 +1 @@ +../operator/chinanet.conf \ No newline at end of file diff --git a/operator6/cmcc.conf b/operator6/cmcc.conf new file mode 120000 index 00000000..0213d77f --- /dev/null +++ b/operator6/cmcc.conf @@ -0,0 +1 @@ +../operator/cmcc.conf \ No newline at end of file diff --git a/operator6/cstnet.conf b/operator6/cstnet.conf new file mode 120000 index 00000000..b9311d1f --- /dev/null +++ b/operator6/cstnet.conf @@ -0,0 +1 @@ +../operator/cstnet.conf \ No newline at end of file diff --git a/operator6/drpeng.conf b/operator6/drpeng.conf new file mode 120000 index 00000000..5b94196d --- /dev/null +++ b/operator6/drpeng.conf @@ -0,0 +1 @@ +../operator/drpeng.conf \ No newline at end of file diff --git a/operator6/tietong.conf b/operator6/tietong.conf new file mode 120000 index 00000000..8631c2c8 --- /dev/null +++ b/operator6/tietong.conf @@ -0,0 +1 @@ +../operator/tietong.conf \ No newline at end of file diff --git a/operator6/unicom.conf b/operator6/unicom.conf new file mode 120000 index 00000000..ff643b3d --- /dev/null +++ b/operator6/unicom.conf @@ -0,0 +1 @@ +../operator/unicom.conf \ No newline at end of file diff --git a/stat.sh b/stat.sh index 2604f894..d4f37d0d 100755 --- a/stat.sh +++ b/stat.sh @@ -4,15 +4,32 @@ source common.sh cd result for file in *.txt; do echo ${file%.*} - cat $file | - awk -F\/ '{print $2}' | - ( - sum=0 - while read n; do - ((s=32-n)) - ((sum+=1<