recover gracefully if no server found

This commit is contained in:
Bastian Doetsch 2022-03-12 11:45:05 +01:00
parent 0bf9fc463a
commit 415cfa8ee7

View File

@ -29,6 +29,9 @@ func main() {
zerolog.SetGlobalLevel(level)
servers := getServers(*typeFlag)
bestIndex := selectBestServerIndex(servers, *countryFlag)
if bestIndex == -1 {
log.Fatal().Str("country", *countryFlag).Msg("No servers for country found.")
}
best := servers[bestIndex]
log.Debug().Interface("server", best).Msg("Best latency server found.")
hostname := strings.TrimSuffix(best.Hostname, "-wireguard")