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