File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,9 +59,10 @@ func (s *Server) IsUp() bool {
5959 return false
6060 }
6161 defer resp .Body .Close ()
62- b , _ := ioutil .ReadAll (resp .Body )
63- if len (b ) > 0 {
62+ b , err := ioutil .ReadAll (resp .Body )
63+ if err != nil || len (b ) > 0 {
6464 log .Debugf ("Failed when parsing get IP result: %s" , b )
65+ return false
6566 }
6667 // only return online if the ping URL returns nothing and 200
6768 return resp .StatusCode == http .StatusOK
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import (
1818 "github.com/librespeed/speedtest-cli/defs"
1919 "github.com/librespeed/speedtest-cli/report"
2020 log "github.com/sirupsen/logrus"
21- "github.com/urfave/cli/v2"
21+ "github.com/urfave/cli/v2"
2222)
2323
2424const (
Original file line number Diff line number Diff line change @@ -321,8 +321,14 @@ func SpeedTest(c *cli.Context) error {
321321
322322 // get the fastest server's index in the `servers` array
323323 var serverIdx int
324- for idx , ping := range pingList {
325- if ping > 0 && ping <= pingList [serverIdx ] {
324+ for idx , newPing := range pingList {
325+ oldPing , ok := pingList [serverIdx ]
326+
327+ if ok {
328+ if newPing > 0 && newPing <= oldPing {
329+ serverIdx = idx
330+ }
331+ } else {
326332 serverIdx = idx
327333 }
328334 }
You can’t perform that action at this time.
0 commit comments