chore(updater): incorporate FetchServers method in Provider interface
- Each provider interface can now fetch updated servers data - Rename each provider updater subpackage name to `updater` - Updater constructor does not take a settings struct - Updater update method takes in a slice of provider strings
This commit is contained in:
@@ -2,6 +2,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/provider"
|
"github.com/qdm12/gluetun/internal/provider"
|
||||||
"github.com/qdm12/gluetun/internal/storage"
|
"github.com/qdm12/gluetun/internal/storage"
|
||||||
|
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpenvpnConfigMaker interface {
|
type OpenvpnConfigMaker interface {
|
||||||
@@ -35,7 +37,13 @@ func (c *CLI) OpenvpnConfig(logger OpenvpnConfigLogger, source sources.Source) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
providerConf := provider.New(*allSettings.VPN.Provider.Name, storage, time.Now)
|
// Unused by this CLI command
|
||||||
|
unzipper := (unzip.Unzipper)(nil)
|
||||||
|
client := (*http.Client)(nil)
|
||||||
|
warner := (Warner)(nil)
|
||||||
|
|
||||||
|
providerConf := provider.New(*allSettings.VPN.Provider.Name, storage, time.Now,
|
||||||
|
warner, client, unzipper)
|
||||||
connection, err := providerConf.GetConnection(allSettings.VPN.Provider.ServerSelection)
|
connection, err := providerConf.GetConnection(allSettings.VPN.Provider.ServerSelection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ func (c *CLI) Update(ctx context.Context, args []string, logger UpdaterLogger) e
|
|||||||
return fmt.Errorf("cannot create servers storage: %w", err)
|
return fmt.Errorf("cannot create servers storage: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
updater := updater.New(options, httpClient, storage, logger)
|
updater := updater.New(httpClient, storage, logger)
|
||||||
err = updater.UpdateServers(ctx)
|
err = updater.UpdateServers(ctx, options.Providers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot update server information: %w", err)
|
return fmt.Errorf("cannot update server information: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,25 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"github.com/qdm12/gluetun/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||||
|
|
||||||
|
type Fetcher interface {
|
||||||
|
FetchServers(ctx context.Context, minServers int) (servers []models.Server, err error)
|
||||||
|
}
|
||||||
|
|
||||||
type ParallelResolver interface {
|
type ParallelResolver interface {
|
||||||
Resolve(ctx context.Context, hosts []string, minToFind int) (
|
Resolve(ctx context.Context, hosts []string, minToFind int) (
|
||||||
hostToIPs map[string][]net.IP, warnings []string, err error)
|
hostToIPs map[string][]net.IP, warnings []string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Unzipper interface {
|
||||||
|
FetchAndExtract(ctx context.Context, url string) (contents map[string][]byte, err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Warner interface {
|
||||||
|
Warn(s string)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,18 +3,21 @@ package custom
|
|||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/openvpn/extract"
|
"github.com/qdm12/gluetun/internal/openvpn/extract"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
extractor extract.Interface
|
extractor extract.Interface
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Provider {
|
func New() *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
extractor: extract.New(),
|
extractor: extract.New(),
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Custom),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Custom),
|
||||||
|
Fetcher: utils.NewNoFetcher(providers.Custom),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/cyberghost/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source) *Provider {
|
||||||
@@ -19,6 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
|
|||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Cyberghost),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Cyberghost),
|
||||||
|
Fetcher: updater.New(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
import "github.com/qdm12/gluetun/internal/constants"
|
import "github.com/qdm12/gluetun/internal/constants"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
func mergeCountryCodes(base, extend map[string]string) (merged map[string]string) {
|
func mergeCountryCodes(base, extend map[string]string) (merged map[string]string) {
|
||||||
merged = make(map[string]string, len(base))
|
merged = make(map[string]string, len(base))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package cyberghost contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Cyberghost provider.
|
// for the Cyberghost provider.
|
||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cyberghost
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ func Test_Provider_GetConnection(t *testing.T) {
|
|||||||
Return(testCase.filteredServers, testCase.storageErr)
|
Return(testCase.filteredServers, testCase.storageErr)
|
||||||
randSource := rand.NewSource(0)
|
randSource := rand.NewSource(0)
|
||||||
|
|
||||||
provider := New(storage, randSource)
|
unzipper := (common.Unzipper)(nil)
|
||||||
|
warner := (common.Warner)(nil)
|
||||||
|
provider := New(storage, randSource, unzipper, warner)
|
||||||
|
|
||||||
if testCase.panicMessage != "" {
|
if testCase.panicMessage != "" {
|
||||||
assert.PanicsWithValue(t, testCase.panicMessage, func() {
|
assert.PanicsWithValue(t, testCase.panicMessage, func() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/expressvpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +13,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Expressvpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Expressvpn),
|
||||||
|
Fetcher: updater.New(unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package expressvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/models"
|
"github.com/qdm12/gluetun/internal/models"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package expressvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// package expressvpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the ExpressVPN provider.
|
// for the ExpressVPN provider.
|
||||||
package expressvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package expressvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/fastestvpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +13,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Fastestvpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Fastestvpn),
|
||||||
|
Fetcher: updater.New(unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package fastestvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package fastestvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package fastestvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package fastestvpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the FastestVPN provider.
|
// for the FastestVPN provider.
|
||||||
package fastestvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package fastestvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package hidemyass
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/hidemyass/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.HideMyAss),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.HideMyAss),
|
||||||
|
Fetcher: updater.New(client, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
func getUniqueHosts(tcpHostToURL, udpHostToURL map[string]string) (
|
func getUniqueHosts(tcpHostToURL, udpHostToURL map[string]string) (
|
||||||
hosts []string) {
|
hosts []string) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package hidemyass contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the HideMyAss provider.
|
// for the HideMyAss provider.
|
||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package hidemyass
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/ipvanish/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +13,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Ipvanish),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Ipvanish),
|
||||||
|
Fetcher: updater.New(unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
//go:generate mockgen -destination=mocks_test.go -package $GOPACKAGE . Warner
|
//go:generate mockgen -destination=mocks_test.go -package $GOPACKAGE . Warner
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Source: github.com/qdm12/gluetun/internal/provider/ipvanish/updater (interfaces: Warner)
|
// Source: github.com/qdm12/gluetun/internal/provider/ipvanish/updater (interfaces: Warner)
|
||||||
|
|
||||||
// Package ipvanish is a generated GoMock package.
|
// Package ipvanish is a generated GoMock package.
|
||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package ipvanish contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Surshark provider.
|
// for the Surshark provider.
|
||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ipvanish
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
@@ -96,7 +97,9 @@ func Test_Provider_GetConnection(t *testing.T) {
|
|||||||
Return(testCase.filteredServers, testCase.storageErr)
|
Return(testCase.filteredServers, testCase.storageErr)
|
||||||
randSource := rand.NewSource(0)
|
randSource := rand.NewSource(0)
|
||||||
|
|
||||||
provider := New(storage, randSource)
|
client := (*http.Client)(nil)
|
||||||
|
warner := (common.Warner)(nil)
|
||||||
|
provider := New(storage, randSource, client, warner)
|
||||||
|
|
||||||
connection, err := provider.GetConnection(testCase.selection)
|
connection, err := provider.GetConnection(testCase.selection)
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package ivpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/ivpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Ivpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Ivpn),
|
||||||
|
Fetcher: updater.New(client, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
//go:generate mockgen -destination=mocks_test.go -package $GOPACKAGE . Warner
|
//go:generate mockgen -destination=mocks_test.go -package $GOPACKAGE . Warner
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Source: github.com/qdm12/gluetun/internal/provider/ivpn/updater (interfaces: Warner)
|
// Source: github.com/qdm12/gluetun/internal/provider/ivpn/updater (interfaces: Warner)
|
||||||
|
|
||||||
// Package ivpn is a generated GoMock package.
|
// Package ivpn is a generated GoMock package.
|
||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package ivpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Surshark provider.
|
// for the Surshark provider.
|
||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package ivpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
@@ -96,7 +97,8 @@ func Test_Provider_GetConnection(t *testing.T) {
|
|||||||
Return(testCase.filteredServers, testCase.storageErr)
|
Return(testCase.filteredServers, testCase.storageErr)
|
||||||
randSource := rand.NewSource(0)
|
randSource := rand.NewSource(0)
|
||||||
|
|
||||||
provider := New(storage, randSource)
|
client := (*http.Client)(nil)
|
||||||
|
provider := New(storage, randSource, client)
|
||||||
|
|
||||||
connection, err := provider.GetConnection(testCase.selection)
|
connection, err := provider.GetConnection(testCase.selection)
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package mullvad
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/mullvad/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Mullvad),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Mullvad),
|
||||||
|
Fetcher: updater.New(client),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package mullvad contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Mullvad provider.
|
// for the Mullvad provider.
|
||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mullvad
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package nordvpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/nordvpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Nordvpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Nordvpn),
|
||||||
|
Fetcher: updater.New(client, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package nordvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package nordvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package nordvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package nordvpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the NordVPN provider.
|
// for the NordVPN provider.
|
||||||
package nordvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package nordvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/perfectprivacy/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +13,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Perfectprivacy),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Perfectprivacy),
|
||||||
|
Fetcher: updater.New(unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package perfectprivacy
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package perfectprivacy
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package perfectprivacy
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package perfectprivacy
|
package updater
|
||||||
|
|
||||||
import "github.com/qdm12/gluetun/internal/updater/unzip"
|
import "github.com/qdm12/gluetun/internal/updater/unzip"
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package privado
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/privado/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,17 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, unzipper common.Unzipper,
|
||||||
|
updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Privado),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Privado),
|
||||||
|
Fetcher: updater.New(client, unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privado
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privado
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privado
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package privado contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Privado provider.
|
// for the Privado provider.
|
||||||
package privado
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privado
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -2,24 +2,27 @@ package privateinternetaccess
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/openvpn"
|
"github.com/qdm12/gluetun/internal/constants/openvpn"
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/privateinternetaccess/updater"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
timeNow func() time.Time
|
timeNow func() time.Time
|
||||||
|
common.Fetcher
|
||||||
// Port forwarding
|
// Port forwarding
|
||||||
portForwardPath string
|
portForwardPath string
|
||||||
authFilePath string
|
authFilePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source,
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
timeNow func() time.Time) *Provider {
|
timeNow func() time.Time, client *http.Client) *Provider {
|
||||||
const jsonPortForwardPath = "/gluetun/piaportforward.json"
|
const jsonPortForwardPath = "/gluetun/piaportforward.json"
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
@@ -27,6 +30,7 @@ func New(storage common.Storage, randSource rand.Source,
|
|||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
portForwardPath: jsonPortForwardPath,
|
portForwardPath: jsonPortForwardPath,
|
||||||
authFilePath: openvpn.AuthConf,
|
authFilePath: openvpn.AuthConf,
|
||||||
|
Fetcher: updater.New(client),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privateinternetaccess
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privateinternetaccess
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package pia contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the Private Internet Access provider.
|
// for the Private Internet Access provider.
|
||||||
package privateinternetaccess
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privateinternetaccess
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/privatevpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +13,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Privatevpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Privatevpn),
|
||||||
|
Fetcher: updater.New(unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package privatevpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the PrivateVPN provider.
|
// for the PrivateVPN provider.
|
||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package privatevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package protonvpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/protonvpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Protonvpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Protonvpn),
|
||||||
|
Fetcher: updater.New(client, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package protonvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package protonvpn
|
package updater
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package protonvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package protonvpn contains code to obtain the server information
|
// Package updater contains code to obtain the server information
|
||||||
// for the ProtonVPN provider.
|
// for the ProtonVPN provider.
|
||||||
package protonvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package protonvpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/models"
|
"github.com/qdm12/gluetun/internal/models"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
"github.com/qdm12/gluetun/internal/provider/custom"
|
"github.com/qdm12/gluetun/internal/provider/custom"
|
||||||
"github.com/qdm12/gluetun/internal/provider/cyberghost"
|
"github.com/qdm12/gluetun/internal/provider/cyberghost"
|
||||||
"github.com/qdm12/gluetun/internal/provider/expressvpn"
|
"github.com/qdm12/gluetun/internal/provider/expressvpn"
|
||||||
@@ -41,6 +42,8 @@ type Provider interface {
|
|||||||
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN) (lines []string)
|
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN) (lines []string)
|
||||||
Name() string
|
Name() string
|
||||||
PortForwarder
|
PortForwarder
|
||||||
|
FetchServers(ctx context.Context, minServers int) (
|
||||||
|
servers []models.Server, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortForwarder interface {
|
type PortForwarder interface {
|
||||||
@@ -57,7 +60,8 @@ type Storage interface {
|
|||||||
GetServerByName(provider, name string) (server models.Server, ok bool)
|
GetServerByName(provider, name string) (server models.Server, ok bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(provider string, storage Storage, timeNow func() time.Time) Provider {
|
func New(provider string, storage Storage, timeNow func() time.Time,
|
||||||
|
updaterWarner common.Warner, client *http.Client, unzipper common.Unzipper) Provider {
|
||||||
randSource := rand.NewSource(timeNow().UnixNano())
|
randSource := rand.NewSource(timeNow().UnixNano())
|
||||||
switch provider {
|
switch provider {
|
||||||
case providers.Custom:
|
case providers.Custom:
|
||||||
@@ -65,43 +69,43 @@ func New(provider string, storage Storage, timeNow func() time.Time) Provider {
|
|||||||
case providers.Cyberghost:
|
case providers.Cyberghost:
|
||||||
return cyberghost.New(storage, randSource)
|
return cyberghost.New(storage, randSource)
|
||||||
case providers.Expressvpn:
|
case providers.Expressvpn:
|
||||||
return expressvpn.New(storage, randSource)
|
return expressvpn.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Fastestvpn:
|
case providers.Fastestvpn:
|
||||||
return fastestvpn.New(storage, randSource)
|
return fastestvpn.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.HideMyAss:
|
case providers.HideMyAss:
|
||||||
return hidemyass.New(storage, randSource)
|
return hidemyass.New(storage, randSource, client, updaterWarner)
|
||||||
case providers.Ipvanish:
|
case providers.Ipvanish:
|
||||||
return ipvanish.New(storage, randSource)
|
return ipvanish.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Ivpn:
|
case providers.Ivpn:
|
||||||
return ivpn.New(storage, randSource)
|
return ivpn.New(storage, randSource, client, updaterWarner)
|
||||||
case providers.Mullvad:
|
case providers.Mullvad:
|
||||||
return mullvad.New(storage, randSource)
|
return mullvad.New(storage, randSource, client)
|
||||||
case providers.Nordvpn:
|
case providers.Nordvpn:
|
||||||
return nordvpn.New(storage, randSource)
|
return nordvpn.New(storage, randSource, client, updaterWarner)
|
||||||
case providers.Perfectprivacy:
|
case providers.Perfectprivacy:
|
||||||
return perfectprivacy.New(storage, randSource)
|
return perfectprivacy.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Privado:
|
case providers.Privado:
|
||||||
return privado.New(storage, randSource)
|
return privado.New(storage, randSource, client, unzipper, updaterWarner)
|
||||||
case providers.PrivateInternetAccess:
|
case providers.PrivateInternetAccess:
|
||||||
return privateinternetaccess.New(storage, randSource, timeNow)
|
return privateinternetaccess.New(storage, randSource, timeNow, client)
|
||||||
case providers.Privatevpn:
|
case providers.Privatevpn:
|
||||||
return privatevpn.New(storage, randSource)
|
return privatevpn.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Protonvpn:
|
case providers.Protonvpn:
|
||||||
return protonvpn.New(storage, randSource)
|
return protonvpn.New(storage, randSource, client, updaterWarner)
|
||||||
case providers.Purevpn:
|
case providers.Purevpn:
|
||||||
return purevpn.New(storage, randSource)
|
return purevpn.New(storage, randSource, client, unzipper, updaterWarner)
|
||||||
case providers.Surfshark:
|
case providers.Surfshark:
|
||||||
return surfshark.New(storage, randSource)
|
return surfshark.New(storage, randSource, client, unzipper, updaterWarner)
|
||||||
case providers.Torguard:
|
case providers.Torguard:
|
||||||
return torguard.New(storage, randSource)
|
return torguard.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.VPNUnlimited:
|
case providers.VPNUnlimited:
|
||||||
return vpnunlimited.New(storage, randSource)
|
return vpnunlimited.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Vyprvpn:
|
case providers.Vyprvpn:
|
||||||
return vyprvpn.New(storage, randSource)
|
return vyprvpn.New(storage, randSource, unzipper, updaterWarner)
|
||||||
case providers.Wevpn:
|
case providers.Wevpn:
|
||||||
return wevpn.New(storage, randSource)
|
return wevpn.New(storage, randSource, updaterWarner)
|
||||||
case providers.Windscribe:
|
case providers.Windscribe:
|
||||||
return windscribe.New(storage, randSource)
|
return windscribe.New(storage, randSource, client, updaterWarner)
|
||||||
default:
|
default:
|
||||||
panic("provider " + provider + " is unknown") // should never occur
|
panic("provider " + provider + " is unknown") // should never occur
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package purevpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||||
"github.com/qdm12/gluetun/internal/provider/common"
|
"github.com/qdm12/gluetun/internal/provider/common"
|
||||||
|
"github.com/qdm12/gluetun/internal/provider/purevpn/updater"
|
||||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,13 +14,16 @@ type Provider struct {
|
|||||||
storage common.Storage
|
storage common.Storage
|
||||||
randSource rand.Source
|
randSource rand.Source
|
||||||
utils.NoPortForwarder
|
utils.NoPortForwarder
|
||||||
|
common.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(storage common.Storage, randSource rand.Source) *Provider {
|
func New(storage common.Storage, randSource rand.Source,
|
||||||
|
client *http.Client, unzipper common.Unzipper, updaterWarner common.Warner) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
randSource: randSource,
|
randSource: randSource,
|
||||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Purevpn),
|
NoPortForwarder: utils.NewNoPortForwarding(providers.Purevpn),
|
||||||
|
Fetcher: updater.New(client, unzipper, updaterWarner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package purevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package purevpn
|
package updater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user