Skip to content

Commit

Permalink
重大bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
badafans committed Mar 8, 2021
1 parent f87c3c2 commit 1e7a7d7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 66 deletions.
28 changes: 12 additions & 16 deletions linux/src/cf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ while true
do
while true
do
declare -i n
declare -i count
rm -rf temp ip.txt data.txt meta.txt log.txt temp.txt
while true
do
Expand Down Expand Up @@ -58,7 +56,7 @@ do
file=$(cat data.txt | grep file= | cut -f 2- -d'=')
url=$(cat data.txt | grep url= | cut -f 2- -d'=')
app=$(cat data.txt | grep app= | cut -f 2- -d'=')
if [ "$app" != "20210307" ]
if [ "$app" != "20210308" ]
then
echo 发现新版本程序: $app
echo 更新地址: $url
Expand All @@ -70,13 +68,10 @@ do
echo $i>>ip.txt
done
rm -rf meta.txt data.txt
n=0
m=$(cat ip.txt | wc -l)
count=m/30+1
./fping -f ip.txt -c $count -i 0 > fping.txt
sort -t/ -k 5n fping.txt | cut -f 1 -d: | sed '31,$d' > ip.txt
./fping -f ip.txt -c 10 -i 0 > fping.txt
sort -t/ -k 5n -k 8n fping.txt | cut -f 1 -d: | sed '21,$d' > ip.txt
rm -rf fping.txt
echo 选取30个丢包率最少的IP地址下载测速
echo 选取20个丢包率最少的IP地址下载测速
mkdir temp
for i in `cat ip.txt`
do
Expand All @@ -88,6 +83,7 @@ do
echo 测速完成
ls -S temp > ip.txt
rm -rf temp
declare -i n
n=$(wc -l ip.txt | awk '{print $1}')
if [ $n -ge 3 ]; then
first=$(sed -n '1p' ip.txt)
Expand Down Expand Up @@ -169,9 +165,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $second
curl --resolve $domain:443:$second https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -247,9 +243,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $third
curl --resolve $domain:443:$third https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -325,9 +321,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
fi
done
Expand All @@ -340,7 +336,7 @@ done
start_seconds=$(date --date="$starttime" +%s)
end_seconds=$(date --date="$endtime" +%s)
clear
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210307-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210308-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
publicip=$(cat temp.txt | grep publicip= | cut -f 2- -d'=')
colo=$(cat temp.txt | grep colo= | cut -f 2- -d'=')
rm -rf temp.txt
Expand Down
30 changes: 14 additions & 16 deletions shell/cf-openwrt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ while true
do
while true
do
declare -i m
declare -i n
declare -i per
declare -i count
rm -rf icmp temp data.txt meta.txt log.txt anycast.txt temp.txt
mkdir icmp
while true
Expand Down Expand Up @@ -60,7 +60,7 @@ do
file=$(cat data.txt | grep file= | cut -f 2- -d'=')
url=$(cat data.txt | grep url= | cut -f 2- -d'=')
app=$(cat data.txt | grep app= | cut -f 2- -d'=')
if [ "$app" != "20210307" ]
if [ "$app" != "20210308" ]
then
echo 发现新版本程序: $app
echo 更新地址: $url
Expand All @@ -72,18 +72,16 @@ do
echo $i>>anycast.txt
done
rm -rf meta.txt data.txt
n=0
m=$(cat anycast.txt | wc -l)
count=m/30+1
for i in `cat anycast.txt`
do
ping -c $count -i 1 -n -q $i > icmp/$n.log&
ping -c 10 -i 1 -n -q $i > icmp/$n.log&
n=$[$n+1]
per=$n*100/$m
while true
do
p=$(ps -ef | grep ping | grep -v "grep" | wc -l)
if [ $p -ge 200 ]
if [ $p -ge 100 ]
then
echo 正在测试 ICMP 丢包率:进程数 $p,已完成 $per %
sleep 1
Expand All @@ -96,7 +94,7 @@ do
rm -rf anycast.txt
while true
do
p=$(ps -ef | grep ping | grep -v "grep" | wc -l)
p=$(ps | grep ping | grep -v "grep" | wc -l)
if [ $p -ne 0 ]
then
echo 等待 ICMP 进程结束:剩余进程数 $p
Expand All @@ -106,9 +104,9 @@ do
break
fi
done
cat icmp/*.log | grep 'statistics\|loss' | sed -n '{N;s/\n/\t/p}' | cut -f 1 -d'%' | awk '{print $NF,$2}' | sort -n | awk '{print $2}' | sed '31,$d' > ip.txt
cat icmp/*.log | grep 'statistics\|loss\|avg' | sed 'N;N;s/\n/ /g' | awk -F, '{print $1,$3}' | awk '{print $2,$9,$15}' | awk -F% '{print $1,$2}' | awk -F/ '{print $1,$2}' | awk '{print $2,$4,$1}' | sort -n | awk '{print $3}' | sed '21,$d' > ip.txt
rm -rf icmp
echo 选取30个丢包率最少的IP地址下载测速
echo 选取20个丢包率最少的IP地址下载测速
mkdir temp
for i in `cat ip.txt`
do
Expand Down Expand Up @@ -201,9 +199,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $second
curl --resolve $domain:443:$second https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -279,9 +277,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $third
curl --resolve $domain:443:$third https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -357,9 +355,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
fi
done
Expand All @@ -372,7 +370,7 @@ done
start_seconds=$(date --date="$starttime" +%s)
end_seconds=$(date --date="$endtime" +%s)
clear
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210307-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210308-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
publicip=$(cat temp.txt | grep publicip= | cut -f 2- -d'=')
colo=$(cat temp.txt | grep colo= | cut -f 2- -d'=')
rm -rf temp.txt
Expand Down
30 changes: 14 additions & 16 deletions shell/cf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ while true
do
while true
do
declare -i m
declare -i n
declare -i per
declare -i count
rm -rf icmp temp data.txt meta.txt log.txt anycast.txt temp.txt
mkdir icmp
while true
Expand Down Expand Up @@ -60,7 +60,7 @@ do
file=$(cat data.txt | grep file= | cut -f 2- -d'=')
url=$(cat data.txt | grep url= | cut -f 2- -d'=')
app=$(cat data.txt | grep app= | cut -f 2- -d'=')
if [ "$app" != "20210307" ]
if [ "$app" != "20210308" ]
then
echo 发现新版本程序: $app
echo 更新地址: $url
Expand All @@ -72,18 +72,16 @@ do
echo $i>>anycast.txt
done
rm -rf meta.txt data.txt
n=0
m=$(cat anycast.txt | wc -l)
count=m/30+1
for i in `cat anycast.txt`
do
ping -c $count -i 0.2 -n -q $i > icmp/$n.log&
ping -c 10 -i 0.2 -n -q $i > icmp/$n.log&
n=$[$n+1]
per=$n*100/$m
while true
do
p=$(ps -ef | grep ping | grep -v "grep" | wc -l)
if [ $p -ge 200 ]
p=$(ps | grep ping | grep -v "grep" | wc -l)
if [ $p -ge 100 ]
then
echo 正在测试 ICMP 丢包率:进程数 $p,已完成 $per %
sleep 0.5
Expand All @@ -106,9 +104,9 @@ do
break
fi
done
cat icmp/*.log | sed -n '3~5p;4~5p' | sed -n '{N;s/\n/\t/p}' | cut -f 1 -d'%' | awk '{print $2,$NF}' | sort -k 2 -n | awk '{print $1}' | sed '31,$d' > ip.txt
cat icmp/*.log | sed -n '3~5p;4~5p;5~5p' | sed 'N;N;s/\n/ /g' | awk -F, '{print $1,$3,$4}' | sort -t' ' -n -k 9 | awk -F/ '{print $1,$5}' | awk '{print $2,$9,$16}' | sort -t' ' -n -k 2 -k 3 | awk '{print $1}' | sed '21,$d' > ip.txt
rm -rf icmp
echo 选取30个丢包率最少的IP地址下载测速
echo 选取20个丢包率最少的IP地址下载测速
mkdir temp
for i in `cat ip.txt`
do
Expand Down Expand Up @@ -201,9 +199,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210307-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$first --retry 3 -s -X POST -d ''20210308-$first-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $second
curl --resolve $domain:443:$second https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -279,9 +277,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210307-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$second --retry 3 -s -X POST -d ''20210308-$second-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
echo 第一次测试 $third
curl --resolve $domain:443:$third https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1
Expand Down Expand Up @@ -357,9 +355,9 @@ do
echo 峰值速度 $max kB/s
if [ $max1 -ge $max2 ]
then
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max1'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
else
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210307-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
curl --ipv4 --resolve service.udpfile.com:443:$third --retry 3 -s -X POST -d ''20210308-$third-$max2'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o /dev/null --connect-timeout 5 --max-time 10
fi
fi
done
Expand All @@ -372,7 +370,7 @@ done
start_seconds=$(date --date="$starttime" +%s)
end_seconds=$(date --date="$endtime" +%s)
clear
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210307-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
curl --ipv4 --resolve service.udpfile.com:443:$anycast --retry 3 -s -X POST -d ''20210308-$anycast-$max'' "https://service.udpfile.com?asn="$asn"&city="$city"" -o temp.txt
publicip=$(cat temp.txt | grep publicip= | cut -f 2- -d'=')
colo=$(cat temp.txt | grep colo= | cut -f 2- -d'=')
rm -rf temp.txt
Expand Down
Loading

0 comments on commit 1e7a7d7

Please sign in to comment.