chore(resolver): export structs instead of interfaces
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/qdm12/gluetun/internal/provider/common (interfaces: Storage)
|
||||
// Source: github.com/qdm12/gluetun/internal/provider/common (interfaces: ParallelResolver,Storage)
|
||||
|
||||
// Package common is a generated GoMock package.
|
||||
package common
|
||||
|
||||
import (
|
||||
context "context"
|
||||
net "net"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
@@ -12,6 +14,45 @@ import (
|
||||
models "github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
// MockParallelResolver is a mock of ParallelResolver interface.
|
||||
type MockParallelResolver struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockParallelResolverMockRecorder
|
||||
}
|
||||
|
||||
// MockParallelResolverMockRecorder is the mock recorder for MockParallelResolver.
|
||||
type MockParallelResolverMockRecorder struct {
|
||||
mock *MockParallelResolver
|
||||
}
|
||||
|
||||
// NewMockParallelResolver creates a new mock instance.
|
||||
func NewMockParallelResolver(ctrl *gomock.Controller) *MockParallelResolver {
|
||||
mock := &MockParallelResolver{ctrl: ctrl}
|
||||
mock.recorder = &MockParallelResolverMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockParallelResolver) EXPECT() *MockParallelResolverMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Resolve mocks base method.
|
||||
func (m *MockParallelResolver) Resolve(arg0 context.Context, arg1 []string, arg2 int) (map[string][]net.IP, []string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Resolve", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(map[string][]net.IP)
|
||||
ret1, _ := ret[1].([]string)
|
||||
ret2, _ := ret[2].(error)
|
||||
return ret0, ret1, ret2
|
||||
}
|
||||
|
||||
// Resolve indicates an expected call of Resolve.
|
||||
func (mr *MockParallelResolverMockRecorder) Resolve(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockParallelResolver)(nil).Resolve), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// MockStorage is a mock of Storage interface.
|
||||
type MockStorage struct {
|
||||
ctrl *gomock.Controller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package common
|
||||
|
||||
// Exceptionally, the storage mock is exported since it is used by all
|
||||
// Exceptionally, these mocks are exported since they are used by all
|
||||
// provider subpackages tests, and it reduces test code duplication a lot.
|
||||
//go:generate mockgen -destination=mocks.go -package $GOPACKAGE . Storage
|
||||
//go:generate mockgen -destination=mocks.go -package $GOPACKAGE . ParallelResolver,Storage
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
package common
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
type ParallelResolver interface {
|
||||
Resolve(ctx context.Context, hosts []string, minToFind int) (
|
||||
hostToIPs map[string][]net.IP, warnings []string, err error)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package cyberghost
|
||||
|
||||
import "github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
}
|
||||
|
||||
func New() *Updater {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() resolver.Parallel {
|
||||
func newParallelResolver() *resolver.Parallel {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxNoNew = 1
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package expressvpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() resolver.Parallel {
|
||||
func newParallelResolver() *resolver.Parallel {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxNoNew = 1
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package fastestvpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() resolver.Parallel {
|
||||
func newParallelResolver() *resolver.Parallel {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 15 * time.Second
|
||||
|
||||
@@ -3,12 +3,12 @@ package hidemyass
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
client *http.Client
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver/mock_resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip/mock_unzip"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -168,7 +168,7 @@ func Test_Updater_GetServers(t *testing.T) {
|
||||
unzipper.EXPECT().FetchAndExtract(ctx, zipURL).
|
||||
Return(testCase.unzipContents, testCase.unzipErr)
|
||||
|
||||
presolver := mock_resolver.NewMockParallel(ctrl)
|
||||
presolver := common.NewMockParallelResolver(ctrl)
|
||||
if testCase.expectResolve {
|
||||
presolver.EXPECT().Resolve(ctx, testCase.hostsToResolve, testCase.minServers).
|
||||
Return(testCase.hostToIPs, testCase.resolveWarnings, testCase.resolveErr)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ipvanish
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
warner Warner
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
}
|
||||
|
||||
type Warner interface {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver/mock_resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -128,7 +128,7 @@ func Test_Updater_GetServers(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
presolver := mock_resolver.NewMockParallel(ctrl)
|
||||
presolver := common.NewMockParallelResolver(ctrl)
|
||||
if testCase.expectResolve {
|
||||
presolver.EXPECT().Resolve(ctx, testCase.hostsToResolve, testCase.minServers).
|
||||
Return(testCase.hostToIPs, testCase.resolveWarnings, testCase.resolveErr)
|
||||
|
||||
@@ -3,12 +3,12 @@ package ivpn
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
client *http.Client
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 30 * time.Second
|
||||
|
||||
@@ -3,14 +3,14 @@ package privado
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
client *http.Client
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 6 * time.Second
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package privatevpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -3,14 +3,14 @@ package purevpn
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
client *http.Client
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -3,14 +3,14 @@ package surfshark
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
client *http.Client
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package torguard
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 5 * time.Second
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package vyprvpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
"github.com/qdm12/gluetun/internal/provider/common"
|
||||
"github.com/qdm12/gluetun/internal/updater/unzip"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
unzipper unzip.Unzipper
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
|
||||
func newParallelResolver() (parallelResolver resolver.Parallel) {
|
||||
func newParallelResolver() (parallelResolver *resolver.Parallel) {
|
||||
const (
|
||||
maxFailRatio = 0.1
|
||||
maxDuration = 20 * time.Second
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package wevpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/updater/resolver"
|
||||
)
|
||||
import "github.com/qdm12/gluetun/internal/provider/common"
|
||||
|
||||
type Updater struct {
|
||||
presolver resolver.Parallel
|
||||
presolver common.ParallelResolver
|
||||
warner Warner
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user