Compare commits

...

5 Commits

4 changed files with 13 additions and 4 deletions

View File

@ -23,6 +23,8 @@ jobs:
- name: Lint source code - name: Lint source code
run: | run: |
make tools lint make tools lint
rm -rf .bin/
rm -rf dist/
- name: Create release tag - name: Create release tag
run: | run: |

View File

@ -7,7 +7,7 @@ before:
builds: builds:
- flags: - flags:
- -trimpath - -trimpath
- env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
goos: goos:
- linux - linux

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

@ -16,12 +16,17 @@ import (
) )
func main() { func main() {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
var outputFlag = flag.String("o", "", "Output format. 'json' outputs server json") var outputFlag = flag.String("o", "", "Output format. 'json' outputs server json")
var countryFlag = flag.String("c", "ch", "Server country code, e.g. ch for Switzerland") var countryFlag = flag.String("c", "ch", "Server country code, e.g. ch for Switzerland")
var typeFlag = flag.String("t", "wireguard", "Server type, e.g. wireguard") var typeFlag = flag.String("t", "wireguard", "Server type, e.g. wireguard")
var logLevel = flag.String("l", "info", "Log level. Allowed values: trace, debug, info, warn, error, fatal, panic")
flag.Parse() flag.Parse()
level, err := zerolog.ParseLevel(*logLevel)
if err != nil {
log.Fatal().Err(err).Msg("Unable to set log level")
}
zerolog.SetGlobalLevel(level)
servers := getServers(*typeFlag) servers := getServers(*typeFlag)
bestIndex := selectBestServerIndex(servers, *countryFlag) bestIndex := selectBestServerIndex(servers, *countryFlag)
best := servers[bestIndex] best := servers[bestIndex]