recover gracefully if no server found
This commit is contained in:
parent
0bf9fc463a
commit
415cfa8ee7
3
main.go
3
main.go
@ -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")
|
||||||
|
Reference in New Issue
Block a user