Skip to content

Commit

Permalink
Unify the preprocessing process of IPv4 and IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyifan committed Aug 13, 2024
1 parent 08191ce commit 90aa058
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
41 changes: 14 additions & 27 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,25 @@ get_asn(){
awk '{gsub(/AS/, ""); print $1 }'
}

prepare_data_v4(){
prepare_data(){
curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt
bgpkit-broker latest -c rrc00 --json | jq -c '.[] | select( .data_type | contains("rib")) | .url' | head -n 1 | xargs axel -q -o rib.gz
stat rib.gz
log_info "runing bgpdump v4 ..."
log_info "runing bgpdump..."
bgpdump -m -O rib.txt rib.gz
stat rib.txt
log_info "finish bgpdump v4"
}
prepare_data_v6(){
bgpkit-broker latest -c route-views6 --json | jq -c '.[] | select( .data_type | contains("rib")) | .url' | head -n 1 | xargs axel -q -o rib6.bz2
stat rib6.bz2
log_info "runing bgpdump v6 ..."
bgpdump -m -O rib6.txt rib6.bz2
stat rib6.txt
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_exit
log_info "finish bgpdump"
}

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
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 changes: 7 additions & 2 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ for file in operator/*.conf; do
operator=${operator##*/}
log_info "generating IP list of $operator ..."
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 -b rib6.txt | grep -v '^::/0$' | cidr-merger -s | grep -F : | cat > result/${operator}6.txt &
(
raw_result=$(mktemp)
get_asn $file | xargs bgptools -b rib.txt > ${raw_result}
cidr-merger -s < ${raw_result} | grep -Fv : | cat > result/${operator}.txt
grep -v '^::/0$' < ${raw_result} | cidr-merger -s | grep -F : | cat > result/${operator}6.txt
rm -f "${raw_result}"
) &
done

wait_exit

0 comments on commit 90aa058

Please sign in to comment.