Files
vpngate/cmd/list.go
Dave Gallant 16aa16c66e Add support for HTTP and SOCKS5 proxies (#127)
As mentioned in https://github.com/davegallant/vpngate/issues/126, adding support for proxies will help bypass issues when vpngate.net is not accessible directly.

This works by:

```sh
# http proxy
sudo vpngate connect --proxy "http://localhost:8080"

# socks5 proxy
sudo vpngate connect --socks5 "127.0.0.1:1080"
```
2024-07-21 14:38:26 -04:00

40 lines
816 B
Go

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(flagProxy, flagSocks5Proxy)
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
},
}