chore(updater): rename GetServers to FetchServers
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
possibleServers := getPossibleServers()
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
servers = hardcodedServers()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://support.fastestvpn.com/download/openvpn-tcp-udp-config-files"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
tcpHostToURL, udpHostToURL, err := getAllHostToURL(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://www.ipvanish.com/software/configs/configs.zip"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -183,7 +183,7 @@ func Test_Updater_GetServers(t *testing.T) {
|
||||
|
||||
updater := New(unzipper, presolver, warner)
|
||||
|
||||
servers, err := updater.GetServers(ctx, testCase.minServers)
|
||||
servers, err := updater.FetchServers(ctx, testCase.minServers)
|
||||
|
||||
assert.Equal(t, testCase.servers, servers)
|
||||
if testCase.err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -142,7 +142,7 @@ func Test_Updater_GetServers(t *testing.T) {
|
||||
|
||||
updater := New(client, presolver, warner)
|
||||
|
||||
servers, err := updater.GetServers(ctx, testCase.minServers)
|
||||
servers, err := updater.FetchServers(ctx, testCase.minServers)
|
||||
|
||||
assert.Equal(t, testCase.servers, servers)
|
||||
if testCase.err != nil {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ var (
|
||||
ErrNotIPv4 = errors.New("IP address is not IPv4")
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
zipURL := url.URL{
|
||||
Scheme: "https",
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://privado.io/apps/ovpn_configs.zip"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
nts := make(nameToServer)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://privatevpn.com/client/PrivateVPN-TUN.zip"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://d32d3g1fvkpl8y.cloudfront.net/heartbleed/windows/New+OVPN+Files.zip"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
hts := make(hostToServer)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const tcpURL = "https://torguard.net/downloads/OpenVPN-TCP-Linux.zip"
|
||||
tcpContents, err := u.unzipper.FetchAndExtract(ctx, tcpURL)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
// Hardcoded data from a user provided ZIP file since it's behind a login wall
|
||||
hts, warnings := getHostToServer()
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://support.vyprvpn.com/hc/article_attachments/360052617332/Vypr_OpenVPN_20200320.zip"
|
||||
contents, err := u.unzipper.FetchAndExtract(ctx, url)
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
ErrGetAPI = errors.New("cannot fetch server information from API")
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
cities := getAvailableCities()
|
||||
servers = make([]models.Server, 0, len(cities))
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
ErrNoWireguardKey = errors.New("no wireguard public key found")
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
if err != nil {
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
func (u *Updater) updateProvider(ctx context.Context, provider string) (err error) {
|
||||
existingServersCount := u.storage.GetServersCount(provider)
|
||||
minServers := getMinServers(existingServersCount)
|
||||
servers, err := u.getServers(ctx, provider, minServers)
|
||||
servers, err := u.fetchServers(ctx, provider, minServers)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot get servers: %w", err)
|
||||
}
|
||||
@@ -51,10 +51,10 @@ func (u *Updater) updateProvider(ctx context.Context, provider string) (err erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *Updater) getServers(ctx context.Context, provider string,
|
||||
func (u *Updater) fetchServers(ctx context.Context, provider string,
|
||||
minServers int) (servers []models.Server, err error) {
|
||||
var providerUpdater interface {
|
||||
GetServers(ctx context.Context, minServers int) (servers []models.Server, err error)
|
||||
FetchServers(ctx context.Context, minServers int) (servers []models.Server, err error)
|
||||
}
|
||||
switch provider {
|
||||
case providers.Custom:
|
||||
@@ -103,7 +103,7 @@ func (u *Updater) getServers(ctx context.Context, provider string,
|
||||
panic("provider " + provider + " is unknown")
|
||||
}
|
||||
|
||||
return providerUpdater.GetServers(ctx, minServers)
|
||||
return providerUpdater.FetchServers(ctx, minServers)
|
||||
}
|
||||
|
||||
func getMinServers(existingServersCount int) (minServers int) {
|
||||
|
||||
Reference in New Issue
Block a user