mirror of
https://github.com/davegallant/vpngate.git
synced 2026-01-15 06:24:07 +00:00
Compare commits
4 Commits
3c98ae8fe3
...
1f226c41ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f226c41ac | ||
|
|
31a76f06cd | ||
|
|
ac218fc82a | ||
|
|
3ad48f1af5 |
24
README.md
24
README.md
@@ -6,7 +6,7 @@ This is a client for [vpngate.net](https://www.vpngate.net/).
|
|||||||
|
|
||||||
This client fetches the list of available relay servers provided by vpngate.net, and allows you to filter and connect to a server of your liking.
|
This client fetches the list of available relay servers provided by vpngate.net, and allows you to filter and connect to a server of your liking.
|
||||||
|
|
||||||
You can check out your current IP address and region at https://ipinfo.io, or run the following:
|
You can check out your current IP address and region at <https://ipinfo.io>, or run the following:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl ipinfo.io
|
curl ipinfo.io
|
||||||
@@ -79,6 +79,28 @@ If the country doesn't matter, a random server can be selected:
|
|||||||
sudo vpngate connect --random
|
sudo vpngate connect --random
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Proxy
|
||||||
|
|
||||||
|
In some cases, anonymity is necessary to populate the list of available VPN servers.
|
||||||
|
|
||||||
|
A proxy is a way to bypass restrictions and in some cases, internet censorship.
|
||||||
|
|
||||||
|
##### HTTP/HTTPS
|
||||||
|
|
||||||
|
Use the specified HTTP/HTTPS proxy to fetch the server list.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo vpngate connect --proxy "http://localhost:8080"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### SOCKS5
|
||||||
|
|
||||||
|
Use the specified SOCKS5 proxy to fetch the server list.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo vpngate connect --socks5 "127.0.0.1:1080"
|
||||||
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- I do not maintain any of the servers on vpngate.net (connect to these servers at your own discretion)
|
- I do not maintain any of the servers on vpngate.net (connect to these servers at your own discretion)
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ import (
|
|||||||
var (
|
var (
|
||||||
flagRandom bool
|
flagRandom bool
|
||||||
flagReconnect bool
|
flagReconnect bool
|
||||||
|
flagProxy string
|
||||||
flagSocks5Proxy string
|
flagSocks5Proxy string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
connectCmd.Flags().BoolVarP(&flagRandom, "random", "r", false, "connect to a random server")
|
connectCmd.Flags().BoolVarP(&flagRandom, "random", "r", false, "connect to a random server")
|
||||||
connectCmd.Flags().BoolVarP(&flagReconnect, "reconnect", "t", false, "continually attempt to connect to the server")
|
connectCmd.Flags().BoolVarP(&flagReconnect, "reconnect", "t", false, "continually attempt to connect to the server")
|
||||||
connectCmd.Flags().StringVarP(&flagSocks5Proxy, "socks5", "s", "", "provide a socks5 proxy server to connect through (i.e. 127.0.0.1:1080")
|
connectCmd.Flags().StringVarP(&flagProxy, "proxy", "p", "", "provide a http/https proxy server to make requests through (i.e. 127.0.0.1:8080")
|
||||||
|
connectCmd.Flags().StringVarP(&flagSocks5Proxy, "socks5", "s", "", "provide a socks5 proxy server to make requests through (i.e. 127.0.0.1:1080")
|
||||||
rootCmd.AddCommand(connectCmd)
|
rootCmd.AddCommand(connectCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ var connectCmd = &cobra.Command{
|
|||||||
Long: `Connect to a vpn from a list of relay servers`,
|
Long: `Connect to a vpn from a list of relay servers`,
|
||||||
Args: cobra.RangeArgs(0, 1),
|
Args: cobra.RangeArgs(0, 1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
vpnServers, err := vpn.GetList(flagSocks5Proxy)
|
vpnServers, err := vpn.GetList(flagProxy, flagSocks5Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Msgf(err.Error())
|
log.Fatal().Msgf(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var listCmd = &cobra.Command{
|
|||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
vpnServers, err := vpn.GetList(flagSocks5Proxy)
|
vpnServers, err := vpn.GetList(flagProxy, flagSocks5Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Msgf(err.Error())
|
log.Fatal().Msgf(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jszwec/csvutil"
|
"github.com/jszwec/csvutil"
|
||||||
@@ -57,7 +58,7 @@ func parseVpnList(r io.Reader) (*[]Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetList returns a list of vpn servers
|
// GetList returns a list of vpn servers
|
||||||
func GetList(socks5Proxy string) (*[]Server, error) {
|
func GetList(httpProxy string, socks5Proxy string) (*[]Server, error) {
|
||||||
cacheExpired := vpnListCacheIsExpired()
|
cacheExpired := vpnListCacheIsExpired()
|
||||||
|
|
||||||
var servers *[]Server
|
var servers *[]Server
|
||||||
@@ -78,7 +79,21 @@ func GetList(socks5Proxy string) (*[]Server, error) {
|
|||||||
|
|
||||||
log.Info().Msg("Fetching the latest server list")
|
log.Info().Msg("Fetching the latest server list")
|
||||||
|
|
||||||
if socks5Proxy != "" {
|
if httpProxy != "" {
|
||||||
|
proxyURL, err := url.Parse(httpProxy)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msgf("Error parsing proxy: %s", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
transport := &http.Transport{
|
||||||
|
Proxy: http.ProxyURL(proxyURL),
|
||||||
|
}
|
||||||
|
|
||||||
|
client = &http.Client{
|
||||||
|
Transport: transport,
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if socks5Proxy != "" {
|
||||||
dialer, err := proxy.SOCKS5("tcp", socks5Proxy, nil, proxy.Direct)
|
dialer, err := proxy.SOCKS5("tcp", socks5Proxy, nil, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Msgf("Error creating SOCKS5 dialer: %v", err)
|
log.Error().Msgf("Error creating SOCKS5 dialer: %v", err)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// TestGetListReal tests getting the real list of vpn servers
|
// TestGetListReal tests getting the real list of vpn servers
|
||||||
func TestGetListReal(t *testing.T) {
|
func TestGetListReal(t *testing.T) {
|
||||||
_, err := GetList("")
|
_, err := GetList("", "")
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user