Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout after 10 seconds to speed up the test on slow routes #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions auto-reroute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mkdir -p ~/.auto-reroute
if [ $(curl -4 -s https://network.feral.io/reroute | grep checked | grep -c 0.0.0.0) = 0 ]; then
echo "Starting off by setting route to default to ensure accurate results."
old_route=$(curl -4 -s https://network.feral.io/reroute | grep checked | awk '{print $(NF-1)}' | sed 's|value=||g' | sed 's/"//g')
timeout 10 curl -4 'https://network.feral.io/reroute' --data "nh=0.0.0.0" >/dev/null 2>&1
curl -m 10 -4 'https://network.feral.io/reroute' --data "nh=0.0.0.0" >/dev/null 2>&1
if [ $? = 124 ]; then
echo "there seems to be an issue with the reroute page..."
error_exit
Expand All @@ -111,6 +111,7 @@ if [ $(curl -4 -s https://network.feral.io/reroute | grep checked | grep -c 0.0.
route_set=1
while [ $route_set = 1 ]; do
route_set=$(curl -4 -s "https://network.feral.io/looking-glass?action=traceroute&host=$ext_IP" | grep -c "$old_route")
sleep 2
done
else
echo "You are currently using the default route"
Expand All @@ -121,7 +122,7 @@ fi
((count++))
echo "Testing single segment download speed from ${route_names[$count]}..."
##need sed now because some european versions of curl insert a , in the speed results
messyspeed=$(echo -n "scale=2; " && curl -4 -s -L ${test_files[$count]} -w "%{speed_download}" -o /dev/null | sed "s/\,/\./g")
messyspeed=$(echo -n "scale=2; " && curl -4 -s -L ${test_files[$count]} -w "%{speed_download}" -m 10 -o /dev/null | sed "s/\,/\./g")
if [ -z "$(echo $messyspeed | awk -F\; '{print $2}'| sed 's/ //g')" ]; then
echo "There was an issue downloading ${test_files[$count]}"
speed="0"
Expand Down