SetServer command actually returns an error if given an invalid server

This commit is contained in:
Alex Dadgar 2018-01-10 10:41:56 -08:00
parent 3f786b904b
commit c8c1284bc3
1 changed files with 10 additions and 0 deletions

View File

@ -602,6 +602,16 @@ func (c *Client) SetServers(in []string) error {
continue
}
// Try to ping to check if it is a real server
ok, err := c.Ping(addr)
if err != nil {
merr.Errors = append(merr.Errors, fmt.Errorf("Server at address %s failed ping: %v", addr, err))
continue
} else if !ok {
merr.Errors = append(merr.Errors, fmt.Errorf("Server at address %s didn't respond to ping", addr))
continue
}
endpoints = append(endpoints, &servers.Server{Addr: addr})
}