mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-14 19:41:51 +00:00
Sync ipv6 omr-test-speed with IPv4 version
This commit is contained in:
parent
094994d166
commit
715e3439e7
1 changed files with 23 additions and 9 deletions
|
@ -1,12 +1,19 @@
|
|||
#!/bin/sh
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
#!/bin/sh
|
||||
# (c) Yannick Chabanois (ycarus@zugaina.org) for OpenMPTCProuter
|
||||
#
|
||||
#
|
||||
|
||||
FORCEVPS=false
|
||||
FASTTEST=false
|
||||
if [ "$1" = "forcevps" ]; then
|
||||
FORCEVPS=true
|
||||
INTERFACE="$2"
|
||||
else
|
||||
INTERFACE="$1"
|
||||
FORCEVPS=true
|
||||
fi
|
||||
if [ "$1" = "fasttest" ]; then
|
||||
FASTTEST=true
|
||||
fi
|
||||
for i in $@; do :; done
|
||||
INTERFACE="$i"
|
||||
|
||||
[ -n "$INTERFACE" ] && [ ! -d "/sys/class/net/$INTERFACE" ] && {
|
||||
echo "You must use a real interface. You wan find them using 'ip a' for example"
|
||||
|
@ -14,7 +21,7 @@ fi
|
|||
}
|
||||
|
||||
|
||||
echo "Select best test server..."
|
||||
[ "$FASTTEST" = true ] || echo "Select best test server..."
|
||||
HOSTLST="http://scaleway.testdebit.info/10G.iso http://bordeaux.testdebit.info/10G.iso http://aix-marseille.testdebit.info/10G.iso http://lyon.testdebit.info/10G.iso http://lille.testdebit.info/10G.iso http://paris.testdebit.info/10G.iso http://appliwave.testdebit.info/10G/10G.iso http://speedtest.frankfurt.linode.com/garbage.php?ckSize=10000 http://speedtest.tokyo2.linode.com/garbage.php?ckSize=10000 http://speedtest.singapore.linode.com/garbage.php?ckSize=10000 http://speedtest.newark.linode.com/garbage.php?ckSize=10000 http://speedtest.atlanta.linode.com/garbage.php?ckSize=10000 http://speedtest.dallas.linode.com/garbage.php?ckSize=10000 http://speedtest.fremont.linode.com/garbage.php?ckSize=10000 https://speed.hetzner.de/10GB.bin http://ipv6.bouygues.testdebit.info/10G.iso http://par.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://ams.download.datapacket.com/10000mb.bin http://fra.download.datapacket.com/10000mb.bin http://lon.download.datapacket.com/10000mb.bin http://mad.download.datapacket.com/10000mb.bin http://prg.download.datapacket.com/10000mb.bin http://sto.download.datapacket.com/10000mb.bin http://vie.download.datapacket.com/10000mb.bin http://war.download.datapacket.com/10000mb.bin http://atl.download.datapacket.com/10000mb.bin http://chi.download.datapacket.com/10000mb.bin http://lax.download.datapacket.com/10000mb.bin http://mia.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://speedtest.milkywan.fr/files/10G.iso"
|
||||
bestping="9999"
|
||||
for pinghost in $HOSTLST; do
|
||||
|
@ -24,7 +31,7 @@ for pinghost in $HOSTLST; do
|
|||
else
|
||||
ping=$(ping -6 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
fi
|
||||
echo "host: $domain - ping: $ping"
|
||||
[ "$FASTTEST" = true ] || echo "host: $domain - ping: $ping"
|
||||
if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then
|
||||
bestping=$ping
|
||||
HOST=$pinghost
|
||||
|
@ -34,11 +41,12 @@ fi
|
|||
|
||||
[ -z "$HOST" ] && HOST="https://speed.hetzner.de/10GB.bin"
|
||||
|
||||
echo "Best server is $HOST, running test:"
|
||||
[ "$FASTTEST" = true ] || echo "Best server is $HOST, running test:"
|
||||
trap : HUP INT TERM
|
||||
if [ -z "$INTERFACE" ]; then
|
||||
curl -6 $HOST >/dev/null || echo
|
||||
else
|
||||
/etc/init.d/sqm stop $INTERFACE
|
||||
domain=$(echo $HOST | awk -F/ '{print $3}')
|
||||
hostip=$(dig +nocmd +noall +answer AAAA $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ')
|
||||
if [ -n "$(ipset list 2>/dev/null | grep ss_rules6)" ]; then
|
||||
|
@ -46,10 +54,16 @@ else
|
|||
ipset add ss_rules6_dst_bypass_all $ip
|
||||
done
|
||||
fi
|
||||
curl -6 --interface $INTERFACE $HOST >/dev/null || echo
|
||||
if [ "$FASTTEST" = true ]; then
|
||||
avg_speed=$(curl -6 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null)
|
||||
echo "$avg_speed"
|
||||
else
|
||||
curl -6 --interface $INTERFACE $HOST >/dev/null || echo
|
||||
fi
|
||||
if [ -n "$(ipset list 2>/dev/null | grep ss_rules6)" ]; then
|
||||
for ip in $hostip; do
|
||||
ipset del ss_rules6_dst_bypass_all $ip
|
||||
done
|
||||
fi
|
||||
/etc/init.d/sqm start $INTERFACE
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue