Add initial prototype (#1)

* Add survey library to select server

* Add speedtest

* Add --random flag to connect

* Add list command

* Cache server list

* Tail the openvpn logs so that it appears in vpngate logs

* Add goreleaser action

* Add golangci-lint action
This commit is contained in:
Dave Gallant
2020-12-31 02:56:01 -05:00
committed by GitHub
parent c52d1e990a
commit a2afbc1e35
17 changed files with 1355 additions and 0 deletions

40
cmd/list.go Normal file
View File

@@ -0,0 +1,40 @@
package cmd
import (
"os"
"strconv"
"github.com/olekukonko/tablewriter"
"github.com/rs/zerolog/log"
"github.com/davegallant/vpngate/pkg/vpn"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(listCmd)
}
var listCmd = &cobra.Command{
Use: "list",
Short: "List all available vpn servers",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
vpnServers, err := vpn.GetList()
if err != nil {
log.Fatal().Msgf(err.Error())
os.Exit(1)
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"#", "HostName", "Country", "Ping", "Score"})
for i, v := range *vpnServers {
table.Append([]string{strconv.Itoa(i + 1), v.HostName, v.CountryLong, v.Ping, strconv.Itoa(v.Score)})
}
table.Render() // Send output
},
}