chore(updater): rename GetServers to FetchServers

This commit is contained in:
Quentin McGaw
2022-06-07 16:47:35 +00:00
parent 11e1c9f9bb
commit 79f213d97a
23 changed files with 26 additions and 26 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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",

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()

View File

@@ -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)

View File

@@ -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))

View File

@@ -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 {

View File

@@ -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) {