chore(updater): shared not enough servers error
This commit is contained in:
5
internal/provider/common/updater.go
Normal file
5
internal/provider/common/updater.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package common
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
@@ -4,15 +4,13 @@ package expressvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
servers = hardcodedServers()
|
||||
@@ -46,7 +44,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,16 +4,14 @@ package fastestvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://support.fastestvpn.com/download/openvpn-tcp-udp-config-files"
|
||||
@@ -22,7 +20,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
hts := make(hostToServer)
|
||||
@@ -53,7 +51,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
@@ -71,7 +69,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,15 +4,13 @@ package hidemyass
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
tcpHostToURL, udpHostToURL, err := getAllHostToURL(ctx, u.client)
|
||||
@@ -24,7 +22,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hosts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hosts), minServers)
|
||||
common.ErrNotEnoughServers, len(hosts), minServers)
|
||||
}
|
||||
|
||||
hostToIPs, warnings, err := resolveHosts(ctx, u.presolver, hosts, minServers)
|
||||
|
||||
@@ -4,18 +4,16 @@ package ipvanish
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://www.ipvanish.com/software/configs/configs.zip"
|
||||
@@ -24,7 +22,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
hts := make(hostToServer)
|
||||
@@ -64,7 +62,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
@@ -82,7 +80,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,15 +4,11 @@ package ivpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
@@ -38,7 +34,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hosts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hosts), minServers)
|
||||
common.ErrNotEnoughServers, len(hosts), minServers)
|
||||
}
|
||||
|
||||
hostToIPs, warnings, err := resolveHosts(ctx, u.presolver, hosts, minServers)
|
||||
|
||||
@@ -4,14 +4,12 @@ package mullvad
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
@@ -28,7 +26,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
servers = hts.toServersSlice()
|
||||
|
||||
@@ -10,12 +10,12 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrParseIP = errors.New("cannot parse IP address")
|
||||
ErrNotIPv4 = errors.New("IP address is not IPv4")
|
||||
ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
ErrParseIP = errors.New("cannot parse IP address")
|
||||
ErrNotIPv4 = errors.New("IP address is not IPv4")
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
@@ -57,7 +57,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -2,17 +2,15 @@ package perfectprivacy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
zipURL := url.URL{
|
||||
@@ -43,7 +41,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(cts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(cts), minServers)
|
||||
common.ErrNotEnoughServers, len(cts), minServers)
|
||||
}
|
||||
|
||||
servers = cts.toServersSlice()
|
||||
|
||||
@@ -4,16 +4,14 @@ package privado
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://privado.io/apps/ovpn_configs.zip"
|
||||
@@ -22,7 +20,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
hts := make(hostToServer)
|
||||
@@ -47,7 +45,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
|
||||
@@ -4,15 +4,13 @@ package privateinternetaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
nts := make(nameToServer)
|
||||
@@ -69,7 +67,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,17 +4,15 @@ package privatevpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://privatevpn.com/client/PrivateVPN-TUN.zip"
|
||||
@@ -23,7 +21,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
countryCodes := constants.CountryCodes()
|
||||
@@ -78,7 +76,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(noHostnameServers)+len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers)+len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(servers)+len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
|
||||
@@ -4,15 +4,13 @@ package protonvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
data, err := fetchAPI(ctx, u.client)
|
||||
@@ -29,7 +27,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if count < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, count, minServers)
|
||||
common.ErrNotEnoughServers, count, minServers)
|
||||
}
|
||||
|
||||
ipToServer := make(ipToServer, count)
|
||||
@@ -60,7 +58,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(ipToServer) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(ipToServer), minServers)
|
||||
common.ErrNotEnoughServers, len(ipToServer), minServers)
|
||||
}
|
||||
|
||||
servers = ipToServer.toServersSlice()
|
||||
|
||||
@@ -4,18 +4,16 @@ package purevpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/publicip"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://d32d3g1fvkpl8y.cloudfront.net/heartbleed/windows/New+OVPN+Files.zip"
|
||||
@@ -24,7 +22,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
hts := make(hostToServer)
|
||||
@@ -57,7 +55,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
@@ -75,7 +73,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
// Get public IP address information
|
||||
|
||||
@@ -4,14 +4,10 @@ package surfshark
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
@@ -48,7 +44,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,18 +4,16 @@ package torguard
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const tcpURL = "https://torguard.net/downloads/OpenVPN-TCP-Linux.zip"
|
||||
@@ -47,7 +45,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
@@ -63,7 +61,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,14 +4,12 @@ package vpnunlimited
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(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
|
||||
@@ -35,7 +33,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -4,16 +4,14 @@ package vyprvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/openvpn"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
const url = "https://support.vyprvpn.com/hc/article_attachments/360052617332/Vypr_OpenVPN_20200320.zip"
|
||||
@@ -22,7 +20,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
return nil, err
|
||||
} else if len(contents) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(contents), minServers)
|
||||
common.ErrNotEnoughServers, len(contents), minServers)
|
||||
}
|
||||
|
||||
hts := make(hostToServer)
|
||||
@@ -61,7 +59,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hts) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(hts), minServers)
|
||||
common.ErrNotEnoughServers, len(hts), minServers)
|
||||
}
|
||||
|
||||
hosts := hts.toHostsSlice()
|
||||
@@ -79,7 +77,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrGetZip = errors.New("cannot get OpenVPN ZIP file")
|
||||
ErrGetAPI = errors.New("cannot fetch server information from API")
|
||||
ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
ErrGetZip = errors.New("cannot get OpenVPN ZIP file")
|
||||
ErrGetAPI = errors.New("cannot fetch server information from API")
|
||||
)
|
||||
|
||||
func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
@@ -40,7 +40,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(hostnameToIPs) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
for hostname, ips := range hostnameToIPs {
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
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) (
|
||||
@@ -69,7 +69,7 @@ func (u *Updater) GetServers(ctx context.Context, minServers int) (
|
||||
|
||||
if len(servers) < minServers {
|
||||
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
||||
ErrNotEnoughServers, len(servers), minServers)
|
||||
common.ErrNotEnoughServers, len(servers), minServers)
|
||||
}
|
||||
|
||||
sortServers(servers)
|
||||
|
||||
Reference in New Issue
Block a user