17 Commits

Author SHA1 Message Date
Dave Gallant
c225d77696 Fix typo in help 2024-07-21 15:26:21 -04:00
Dave Gallant
c1548a3378 Update .goreleaser.yaml 2024-07-21 15:21:43 -04:00
Dave Gallant
86a0869bb5 Migrate to goreleaser v2 2024-07-21 15:12:00 -04:00
Dave Gallant
0ec8aa1977 Fix goreleaser action 2024-07-21 14:54:48 -04:00
Dave Gallant
667783899e Bump go-releaser workflow to go 1.22 2024-07-21 14:49:09 -04:00
renovate[bot]
ef99491fa6 Update module golang.org/x/net to v0.27.0 (#130)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-21 14:41:54 -04:00
renovate[bot]
4d458e4d47 Update module golang.org/x/net to v0.23.0 [SECURITY] (#129)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-21 14:40:08 -04:00
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
renovate[bot]
5850876efa Update goreleaser/goreleaser-action action to v6 (#124)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-20 20:35:01 -04:00
renovate[bot]
98426b012d Update module github.com/spf13/cobra to v1.8.1 (#125)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-20 20:34:50 -04:00
Dave Gallant
679a63cc14 Update renovate.json 2024-06-28 12:02:56 -04:00
renovate[bot]
a6e6fc992f Update module github.com/rs/zerolog to v1.33.0 (#123)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-23 07:08:12 -04:00
renovate[bot]
830b40f945 Update golangci/golangci-lint-action action to v6 (#122)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 06:57:07 -04:00
renovate[bot]
950ef75855 Update module github.com/stretchr/testify to v1.9.0 (#120)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-02 10:36:32 -05:00
renovate[bot]
9768124578 Update golangci/golangci-lint-action action to v4 (#119)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 17:04:37 -05:00
renovate[bot]
88c77db4c2 Update module github.com/rs/zerolog to v1.32.0 (#118)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-04 11:21:05 -05:00
renovate[bot]
12e76d6443 Update module github.com/jszwec/csvutil to v1.10.0 (#117)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-04 09:10:01 -05:00
11 changed files with 141 additions and 54 deletions

View File

@@ -18,7 +18,7 @@ jobs:
go-version: 1.19
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.49
- name: test

View File

@@ -18,13 +18,13 @@ jobs:
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: "1.22"
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
CGO_ENABLED: 0

View File

@@ -1,36 +1,38 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=jcroql
version: 2
before:
hooks:
- go mod tidy
- go get -v
- rm -rf dist
builds:
-
env:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w
goos:
- darwin
- linux
- darwin
goarch:
- amd64
- arm
- arm64
archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
goarm:
- "7"
ldflags:
- -s -w
mod_timestamp: "{{ .CommitTimestamp }}"
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
use: github
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
release:
github:
owner: davegallant
@@ -38,12 +40,12 @@ release:
# Check https://goreleaser.com/customization/homebrew/
brews:
- homepage: 'https://github.com/davegallant/homebrew-public'
description: 'a client for vpngate.net'
folder: Formula
- homepage: "https://github.com/davegallant/homebrew-public"
description: "a client for vpngate.net"
directory: Formula
commit_author:
name: davegallant
email: davegallant@gmail.com
tap:
repository:
owner: davegallant
name: homebrew-public

View File

@@ -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.
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
curl ipinfo.io
@@ -79,6 +79,28 @@ If the country doesn't matter, a random server can be selected:
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
- I do not maintain any of the servers on vpngate.net (connect to these servers at your own discretion)

View File

@@ -18,11 +18,15 @@ import (
var (
flagRandom bool
flagReconnect bool
flagProxy string
flagSocks5Proxy string
)
func init() {
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().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)
}
@@ -33,7 +37,7 @@ var connectCmd = &cobra.Command{
Long: `Connect to a vpn from a list of relay servers`,
Args: cobra.RangeArgs(0, 1),
Run: func(cmd *cobra.Command, args []string) {
vpnServers, err := vpn.GetList()
vpnServers, err := vpn.GetList(flagProxy, flagSocks5Proxy)
if err != nil {
log.Fatal().Msgf(err.Error())
os.Exit(1)

View File

@@ -22,7 +22,7 @@ var listCmd = &cobra.Command{
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
vpnServers, err := vpn.GetList()
vpnServers, err := vpn.GetList(flagProxy, flagSocks5Proxy)
if err != nil {
log.Fatal().Msgf(err.Error())
os.Exit(1)

15
go.mod
View File

@@ -4,14 +4,15 @@ go 1.19
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/jszwec/csvutil v1.9.0
github.com/jszwec/csvutil v1.10.0
github.com/juju/errors v1.0.0
github.com/nxadm/tail v1.4.11
github.com/olekukonko/tablewriter v0.0.5
github.com/rs/zerolog v1.31.0
github.com/rs/zerolog v1.33.0
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.27.0
)
require (
@@ -28,9 +29,9 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

35
go.sum
View File

@@ -4,6 +4,7 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
@@ -17,8 +18,8 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jszwec/csvutil v1.9.0 h1:iTmq9G1P0e+AUq/MkFg6tetJ+1BH3fOX8Xi0RAcwiGc=
github.com/jszwec/csvutil v1.9.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I=
github.com/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI=
github.com/jszwec/csvutil v1.10.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I=
github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM=
github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5Qe8=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
@@ -57,19 +58,21 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -77,6 +80,12 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -91,16 +100,26 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

View File

@@ -4,9 +4,12 @@ import (
"bytes"
"io"
"net/http"
"net/url"
"os"
"github.com/jszwec/csvutil"
"github.com/rs/zerolog/log"
"golang.org/x/net/proxy"
"github.com/davegallant/vpngate/pkg/util"
"github.com/juju/errors"
@@ -55,10 +58,11 @@ func parseVpnList(r io.Reader) (*[]Server, error) {
}
// GetList returns a list of vpn servers
func GetList() (*[]Server, error) {
func GetList(httpProxy string, socks5Proxy string) (*[]Server, error) {
cacheExpired := vpnListCacheIsExpired()
var servers *[]Server
var client *http.Client
if !cacheExpired {
servers, err := getVpnListCache()
@@ -75,11 +79,43 @@ func GetList() (*[]Server, error) {
log.Info().Msg("Fetching the latest server list")
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)
if err != nil {
log.Error().Msgf("Error creating SOCKS5 dialer: %v", err)
os.Exit(1)
}
httpTransport := &http.Transport{
Dial: dialer.Dial,
}
client = &http.Client{
Transport: httpTransport,
}
} else {
client = &http.Client{}
}
var r *http.Response
err := util.Retry(5, 1, func() error {
var err error
r, err = http.Get(vpnList)
r, err = client.Get(vpnList)
if err != nil {
return err
}

View File

@@ -9,7 +9,7 @@ import (
// TestGetListReal tests getting the real list of vpn servers
func TestGetListReal(t *testing.T) {
_, err := GetList()
_, err := GetList("", "")
assert.NoError(t, err)
}

View File

@@ -1,5 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"schedule": [
"every weekend"
],
"extends": [
"config:recommended"
]