Compare commits

...

1 Commits

Author SHA1 Message Date
415cfa8ee7 recover gracefully if no server found 2022-03-12 11:45:41 +01:00

View File

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