mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add Upload test support to omr-speedtest
This commit is contained in:
parent
7bd47e4502
commit
6bf803f927
1 changed files with 19 additions and 3 deletions
|
@ -74,34 +74,50 @@ bypass_host_disable() {
|
||||||
/etc/init.d/sqm start $INTERFACE
|
/etc/init.d/sqm start $INTERFACE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ -f /usr/bin/v2ray ]; then
|
||||||
|
upload_file="/usr/bin/v2ray"
|
||||||
|
elif [ -f /usr/bin/xray ]; then
|
||||||
|
upload_file="/usr/bin/xray"
|
||||||
|
elif [ -f /boot/vmlinuz ]; then
|
||||||
|
upload_file="/boot/vmlinuz"
|
||||||
|
elif [ -f /bin/bash ]; then
|
||||||
|
upload_file="/bin/bash"
|
||||||
|
else
|
||||||
|
upload_file="/bin/busybox"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Download server list..."
|
echo "Download server list..."
|
||||||
wget -q -O /tmp/speedtest.lst https://www.speedtest.net/api/js/servers
|
wget -q -O /tmp/speedtest.lst https://www.speedtest.net/api/js/servers
|
||||||
bestuploadurl=""
|
bestuploadurl=""
|
||||||
besthost=""
|
besthost=""
|
||||||
bestpinghost=""
|
bestpinghost=""
|
||||||
|
sponsor=""
|
||||||
bestping="999"
|
bestping="999"
|
||||||
echo "Select best server..."
|
echo "Select best server..."
|
||||||
while read line; do
|
while read line; do
|
||||||
host=$(echo $line | jsonfilter -e '@.host')
|
host=$(echo $line | jsonfilter -e '@.host')
|
||||||
pinghost=$(echo $host | awk -F: '{print $1}')
|
pinghost=$(echo $host | awk -F: '{print $1}')
|
||||||
uploadurl=$(echo $line | jsonfilter -e '@.host')
|
url=$(echo $line | jsonfilter -e '@.url')
|
||||||
ping=$(ping -c1 -w1 $pinghost | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
|
ping=$(ping -c1 -w1 $pinghost | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
|
||||||
echo -n "."
|
echo -n "."
|
||||||
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
|
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
|
||||||
bestping=$ping
|
bestping=$ping
|
||||||
bestuploadurl=$uploadurl
|
besturl=$url
|
||||||
besthost=$host
|
besthost=$host
|
||||||
bestpinghost=$pinghost
|
bestpinghost=$pinghost
|
||||||
|
sponsor=$(echo $line | jsonfilter -q -e '@.sponsor')
|
||||||
fi
|
fi
|
||||||
done < <(cat /tmp/speedtest.lst | jsonfilter -e '@[*]')
|
done < <(cat /tmp/speedtest.lst | jsonfilter -e '@[*]')
|
||||||
echo
|
echo
|
||||||
echo "Done: url: $bestuploadurl - host: $besthost - ping: $bestping"
|
echo "Done: url: $besturl - host: $besthost - ping: $bestping - sponsor: $sponsor"
|
||||||
echo "Download test:"
|
echo "Download test:"
|
||||||
if [ -z "$INTERFACE" ]; then
|
if [ -z "$INTERFACE" ]; then
|
||||||
curl -4 $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
|
curl -4 $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
|
||||||
else
|
else
|
||||||
bypass_host_enable $INTERFACE $bestpinghost
|
bypass_host_enable $INTERFACE $bestpinghost
|
||||||
|
echo "Download:"
|
||||||
curl -4 --interface $INTERFACE $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
|
curl -4 --interface $INTERFACE $besthost/speedtest/random7000x7000.jpg >/dev/null || echo
|
||||||
|
echo "Upload:"
|
||||||
|
curl -4 --interface $INTERFACE -F "file=@$upload_file" $besturl >/dev/null || echo
|
||||||
bypass_host_disable $INTERFACE $bestpinghost
|
bypass_host_disable $INTERFACE $bestpinghost
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue