Last active
November 22, 2024 11:53
-
-
Save Ansen/bede7ede0db7558bb323c70e50f2dfd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function speed_test_by_url(){ | |
local url=$1 | |
for x in $(curl -qs "$url") | |
do | |
speed=$(curl --max-time 10 --resolve cdn.cloudflare.steamstatic.com:443:$x https://cdn.cloudflare.steamstatic.com/steam/apps/256843155/movie_max.mp4 -kw "%{speed_download}" -o /dev/null) | |
speed=$(echo $speed| awk -F. '{print $1}') | |
speed=$((speed / 1024 / 1024)) | |
echo "ip: $x speed: $speed Mb/s" | |
if [[ ${speed} -gt ${low_speed} ]] | |
then | |
break | |
fi | |
done | |
} | |
function speed_test_by_ip(){ | |
local ip=$1 | |
speed=$(curl --max-time 10 --resolve cdn.cloudflare.steamstatic.com:443:$ip https://cdn.cloudflare.steamstatic.com/steam/apps/256843155/movie_max.mp4 -kw "%{speed_download}" -o /dev/null) | |
speed=$(echo $speed| awk -F. '{print $1}') | |
speed=$((speed / 1024 / 1024)) | |
echo "ip: $ip speed: $speed Mb/s" | |
} | |
function main(){ | |
ali_jp_url='https://fastly.jsdelivr.net/gh/ip-scanner/cloudflare@daily/Alibaba%20Cloud%20-%20%E6%97%A5%E6%9C%AC%20%E4%B8%9C%E4%BA%AC.txt' | |
azure_jp_url='https://fastly.jsdelivr.net/gh/ip-scanner/cloudflare@daily/Microsoft%20Azure%20-%20%E6%97%A5%E6%9C%AC%20%E4%B8%9C%E4%BA%AC.txt' | |
url_list="${azure_jp_url} ${ali_jp_url}" | |
# 最低速度 | |
low_speed=10 | |
if [[ "x${1}" == "x" ]] | |
then | |
for u in $(echo $url_list) | |
do | |
speed_test_by_url "$u" | |
done | |
else | |
speed_test_by_ip $1 | |
fi | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment