mirror of
https://github.com/gaoyifan/china-operator-ip.git
synced 2025-07-13 21:02:37 +08:00
Adapt bgptolls 0.1.1
This commit is contained in:
parent
54f139f710
commit
ce1946dcd1
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -12,9 +12,9 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: macos-latest
|
||||||
env:
|
env:
|
||||||
BGPTOOLS_VERSION: 0.0.3
|
BGPTOOLS_VERSION: 0.1.1
|
||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.16
|
||||||
- run: sudo apt-get install -y lftp bgpdump tree
|
- run: brew install lftp tree
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
key: ${{ runner.os }}-build-dependencies
|
key: ${{ runner.os }}-build-dependencies
|
||||||
|
35
common.sh
35
common.sh
@ -13,43 +13,30 @@ get_asn(){
|
|||||||
unset EXCLUDE
|
unset EXCLUDE
|
||||||
source $CONF_FILE
|
source $CONF_FILE
|
||||||
EXCLUDE=${EXCLUDE:-"^$"}
|
EXCLUDE=${EXCLUDE:-"^$"}
|
||||||
grep -P "${COUNTRY}\$" asnames.txt |
|
egrep "${COUNTRY}\$" asnames.txt |
|
||||||
grep -Pi "$PATTERN" |
|
egrep -i "$PATTERN" |
|
||||||
grep -vPi "$EXCLUDE" |
|
egrep -vi "$EXCLUDE" |
|
||||||
awk '{gsub(/AS/, ""); print $1 }'
|
awk '{gsub(/AS/, ""); print $1 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_data_v4(){
|
prepare_data_v4(){
|
||||||
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 ..."
|
log_info "unzip v4 ..."
|
||||||
bgpdump -m -O rib.txt rib.bz2
|
bzip2 -d rib.bz2
|
||||||
log_info "finish bgpdump v4"
|
log_info "unzip v4 finish"
|
||||||
}
|
}
|
||||||
prepare_data_v6(){
|
prepare_data_v6(){
|
||||||
IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata"
|
IP6UPSTREAM="http://archive.routeviews.org/route-views6/bgpdata"
|
||||||
MONTH6=$(date -u +%Y.%m)
|
MONTH6=$(date -u +%Y.%m)
|
||||||
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 v6 ..."
|
log_info "unzip v6 ..."
|
||||||
bgpdump -m -O rib6.txt rib6.bz2
|
bzip2 -d rib6.bz2
|
||||||
log_info "finish bgpdump v6"
|
log_info "unzip v6 finish"
|
||||||
}
|
}
|
||||||
prepare_data(){
|
prepare_data(){
|
||||||
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt &
|
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt &
|
||||||
prepare_data_v4 &
|
prepare_data_v4
|
||||||
prepare_data_v6 &
|
prepare_data_v6
|
||||||
wait_exit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_exit(){
|
|
||||||
local oldstate=$(set +o)
|
|
||||||
set +e
|
|
||||||
local s=0
|
|
||||||
while [[ $s -ne 127 ]]; do
|
|
||||||
[[ $s -ne 0 ]] && exit $s
|
|
||||||
wait -n
|
|
||||||
s=$?
|
|
||||||
done
|
|
||||||
eval "$oldstate"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
@ -9,8 +9,6 @@ for file in operator/*.conf; do
|
|||||||
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 | cidr-merger -s | grep -Fv : | cat > result/${operator}.txt &
|
get_asn $file | xargs bgptools -m rib | cidr-merger -s | grep -Fv : | cat > result/${operator}.txt
|
||||||
get_asn $file | xargs bgptools -b rib6.txt | cidr-merger -s | grep -F : | cat > result/${operator}6.txt &
|
get_asn $file | xargs bgptools -m rib6 | cidr-merger -s | grep -F : | cat > result/${operator}6.txt
|
||||||
done
|
done
|
||||||
|
|
||||||
wait_exit
|
|
||||||
|
Loading…
Reference in New Issue
Block a user