feat(vpn): rotate filtered servers on internal vpn restarts

- Fix #290
This commit is contained in:
Quentin McGaw
2026-05-04 03:28:48 +00:00
parent 4b819b4dbb
commit fed09562e5
57 changed files with 345 additions and 220 deletions
+1 -1
View File
@@ -11,5 +11,5 @@ func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Support
) {
defaults := utils.NewConnectionDefaults(443, 1194, 58237) //nolint:mnd
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, ipv6Supported, p.randSource)
p.storage, selection, defaults, ipv6Supported, p.connPicker)
}
+1 -3
View File
@@ -2,7 +2,6 @@ package ivpn
import (
"errors"
"math/rand"
"net/http"
"net/netip"
"testing"
@@ -91,12 +90,11 @@ func Test_Provider_GetConnection(t *testing.T) {
storage := common.NewMockStorage(ctrl)
storage.EXPECT().FilterServers(provider, testCase.selection).
Return(testCase.filteredServers, testCase.storageErr)
randSource := rand.NewSource(0)
client := (*http.Client)(nil)
warner := (common.Warner)(nil)
parallelResolver := (common.ParallelResolver)(nil)
provider := New(storage, randSource, client, warner, parallelResolver)
provider := New(storage, client, warner, parallelResolver)
connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported)
+4 -5
View File
@@ -1,27 +1,26 @@
package ivpn
import (
"math/rand"
"net/http"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/provider/common"
"github.com/qdm12/gluetun/internal/provider/ivpn/updater"
"github.com/qdm12/gluetun/internal/provider/utils"
)
type Provider struct {
storage common.Storage
randSource rand.Source
connPicker *utils.ConnectionPicker
common.Fetcher
}
func New(storage common.Storage, randSource rand.Source,
client *http.Client, updaterWarner common.Warner,
func New(storage common.Storage, client *http.Client, updaterWarner common.Warner,
parallelResolver common.ParallelResolver,
) *Provider {
return &Provider{
storage: storage,
randSource: randSource,
connPicker: utils.NewConnectionPicker(),
Fetcher: updater.New(client, updaterWarner, parallelResolver),
}
}