Compare commits

..

2 Commits

Author SHA1 Message Date
415cfa8ee7 recover gracefully if no server found 2022-03-12 11:45:41 +01:00
0bf9fc463a Update README.md 2022-03-12 11:28:58 +01:00
2 changed files with 5 additions and 0 deletions

View File

@ -17,6 +17,8 @@ Execute `mullvad-best-server`. It outputs the code, e.g. `de05`. You can then co
Usage of dist/mullvad-best-server_darwin_amd64/mullvad-best-server: Usage of dist/mullvad-best-server_darwin_amd64/mullvad-best-server:
-c string -c string
Server country code, e.g. ch for Switzerland (default "ch") Server country code, e.g. ch for Switzerland (default "ch")
-l string
Log level. Allowed values: trace, debug, info, warn, error, fatal, panic (default "info")
-o string -o string
Output format. 'json' outputs server json Output format. 'json' outputs server json
-t string -t string

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")