diff --git a/internal/cli/openvpnconfig.go b/internal/cli/openvpnconfig.go index 37e93332..41bc6696 100644 --- a/internal/cli/openvpnconfig.go +++ b/internal/cli/openvpnconfig.go @@ -71,7 +71,8 @@ func (c *CLI) OpenvpnConfig(logger OpenvpnConfigLogger, source Source, providers := provider.NewProviders(storage, time.Now, warner, client, unzipper, parallelResolver, ipFetcher, openvpnFileExtractor) providerConf := providers.Get(*allSettings.VPN.Provider.Name) - connection, err := providerConf.GetConnection(allSettings.VPN.Provider.ServerSelection) + connection, err := providerConf.GetConnection( + allSettings.VPN.Provider.ServerSelection, ipv6Supported) if err != nil { return err } diff --git a/internal/provider/custom/connection.go b/internal/provider/custom/connection.go index b5b426d3..7490d7ec 100644 --- a/internal/provider/custom/connection.go +++ b/internal/provider/custom/connection.go @@ -15,7 +15,7 @@ var ( ) // GetConnection gets the connection from the OpenVPN configuration file. -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { switch selection.VPN { case vpn.OpenVPN: diff --git a/internal/provider/cyberghost/connection.go b/internal/provider/cyberghost/connection.go index 36ded82f..2d2dc21d 100644 --- a/internal/provider/cyberghost/connection.go +++ b/internal/provider/cyberghost/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 443, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/example/connection.go b/internal/provider/example/connection.go index a057b2f2..87724c6c 100644 --- a/internal/provider/example/connection.go +++ b/internal/provider/example/connection.go @@ -6,11 +6,11 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { // TODO: Set the default ports for each VPN protocol+network protocol // combination. If one combination is not supported, set it to `0`. defaults := utils.NewConnectionDefaults(443, 1194, 51820) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/expressvpn/connection.go b/internal/provider/expressvpn/connection.go index fd48a366..1644a33d 100644 --- a/internal/provider/expressvpn/connection.go +++ b/internal/provider/expressvpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 1195, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/expressvpn/connection_test.go b/internal/provider/expressvpn/connection_test.go index b7160088..5bc88d8a 100644 --- a/internal/provider/expressvpn/connection_test.go +++ b/internal/provider/expressvpn/connection_test.go @@ -28,6 +28,7 @@ func Test_Provider_GetConnection(t *testing.T) { filteredServers []models.Server storageErr error selection settings.ServerSelection + ipv6Supported bool connection models.Connection errWrapped error errMessage string @@ -94,12 +95,12 @@ func Test_Provider_GetConnection(t *testing.T) { if testCase.panicMessage != "" { assert.PanicsWithValue(t, testCase.panicMessage, func() { - _, _ = provider.GetConnection(testCase.selection) + _, _ = provider.GetConnection(testCase.selection, testCase.ipv6Supported) }) return } - connection, err := provider.GetConnection(testCase.selection) + connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported) assert.ErrorIs(t, err, testCase.errWrapped) if testCase.errWrapped != nil { diff --git a/internal/provider/fastestvpn/connection.go b/internal/provider/fastestvpn/connection.go index 4c1ef7ff..b525b2f2 100644 --- a/internal/provider/fastestvpn/connection.go +++ b/internal/provider/fastestvpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(4443, 4443, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/hidemyass/connection.go b/internal/provider/hidemyass/connection.go index d277a434..7768841a 100644 --- a/internal/provider/hidemyass/connection.go +++ b/internal/provider/hidemyass/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(8080, 553, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/ipvanish/connection.go b/internal/provider/ipvanish/connection.go index 751a7e83..fd6c095c 100644 --- a/internal/provider/ipvanish/connection.go +++ b/internal/provider/ipvanish/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 443, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/ivpn/connection.go b/internal/provider/ivpn/connection.go index 58c9df77..498c7067 100644 --- a/internal/provider/ivpn/connection.go +++ b/internal/provider/ivpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 58237) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/ivpn/connection_test.go b/internal/provider/ivpn/connection_test.go index 3fd1fe4c..90b4621c 100644 --- a/internal/provider/ivpn/connection_test.go +++ b/internal/provider/ivpn/connection_test.go @@ -29,6 +29,7 @@ func Test_Provider_GetConnection(t *testing.T) { filteredServers []models.Server storageErr error selection settings.ServerSelection + ipv6Supported bool connection models.Connection errWrapped error errMessage string @@ -103,7 +104,7 @@ func Test_Provider_GetConnection(t *testing.T) { parallelResolver := (common.ParallelResolver)(nil) provider := New(storage, randSource, client, warner, parallelResolver) - connection, err := provider.GetConnection(testCase.selection) + connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported) assert.ErrorIs(t, err, testCase.errWrapped) if testCase.errWrapped != nil { diff --git a/internal/provider/mullvad/connection.go b/internal/provider/mullvad/connection.go index a29951ed..a7110767 100644 --- a/internal/provider/mullvad/connection.go +++ b/internal/provider/mullvad/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 51820) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/mullvad/connection_test.go b/internal/provider/mullvad/connection_test.go index 3eabab16..e9bb7bbd 100644 --- a/internal/provider/mullvad/connection_test.go +++ b/internal/provider/mullvad/connection_test.go @@ -29,6 +29,7 @@ func Test_Provider_GetConnection(t *testing.T) { filteredServers []models.Server storageErr error selection settings.ServerSelection + ipv6Supported bool connection models.Connection errWrapped error errMessage string @@ -101,7 +102,7 @@ func Test_Provider_GetConnection(t *testing.T) { client := (*http.Client)(nil) provider := New(storage, randSource, client) - connection, err := provider.GetConnection(testCase.selection) + connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported) assert.ErrorIs(t, err, testCase.errWrapped) if testCase.errWrapped != nil { diff --git a/internal/provider/nordvpn/connection.go b/internal/provider/nordvpn/connection.go index 00230121..e3b8b7fc 100644 --- a/internal/provider/nordvpn/connection.go +++ b/internal/provider/nordvpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/perfectprivacy/connection.go b/internal/provider/perfectprivacy/connection.go index a51bdeb0..778f6e29 100644 --- a/internal/provider/perfectprivacy/connection.go +++ b/internal/provider/perfectprivacy/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 443, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/privado/connection.go b/internal/provider/privado/connection.go index dcb06111..a237b318 100644 --- a/internal/provider/privado/connection.go +++ b/internal/provider/privado/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/privateinternetaccess/connection.go b/internal/provider/privateinternetaccess/connection.go index 7c30f981..1f06fa2a 100644 --- a/internal/provider/privateinternetaccess/connection.go +++ b/internal/provider/privateinternetaccess/connection.go @@ -7,7 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { // Set port defaults depending on encryption preset. var defaults utils.ConnectionDefaults @@ -21,5 +21,5 @@ func (p *Provider) GetConnection(selection settings.ServerSelection) ( } return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/privatevpn/connection.go b/internal/provider/privatevpn/connection.go index 6d84a9aa..55de3b62 100644 --- a/internal/provider/privatevpn/connection.go +++ b/internal/provider/privatevpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/protonvpn/connection.go b/internal/provider/protonvpn/connection.go index 14c58344..ef9c7973 100644 --- a/internal/provider/protonvpn/connection.go +++ b/internal/provider/protonvpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 8212762e..c903cb53 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -12,7 +12,7 @@ import ( // Provider contains methods to read and modify the openvpn configuration to connect as a client. type Provider interface { - GetConnection(selection settings.ServerSelection) (connection models.Connection, err error) + GetConnection(selection settings.ServerSelection, ipv6Supported bool) (connection models.Connection, err error) OpenVPNConfig(connection models.Connection, settings settings.OpenVPN, ipv6Supported bool) (lines []string) Name() string PortForwarder diff --git a/internal/provider/purevpn/connection.go b/internal/provider/purevpn/connection.go index cc809cf1..ab06b3eb 100644 --- a/internal/provider/purevpn/connection.go +++ b/internal/provider/purevpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(80, 53, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/slickvpn/connection.go b/internal/provider/slickvpn/connection.go index 4aee167e..361f3edd 100644 --- a/internal/provider/slickvpn/connection.go +++ b/internal/provider/slickvpn/connection.go @@ -6,8 +6,8 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 443, 0) //nolint:gomnd - return utils.GetConnection(p.Name(), p.storage, selection, defaults, p.randSource) + return utils.GetConnection(p.Name(), p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/surfshark/connection.go b/internal/provider/surfshark/connection.go index 0e919a99..d6ff6ee5 100644 --- a/internal/provider/surfshark/connection.go +++ b/internal/provider/surfshark/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(1443, 1194, 51820) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/torguard/connection.go b/internal/provider/torguard/connection.go index 02748079..67c2d913 100644 --- a/internal/provider/torguard/connection.go +++ b/internal/provider/torguard/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(1912, 1912, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/utils/connection.go b/internal/provider/utils/connection.go index 24887a61..61211e60 100644 --- a/internal/provider/utils/connection.go +++ b/internal/provider/utils/connection.go @@ -33,6 +33,7 @@ func GetConnection(provider string, storage Storage, selection settings.ServerSelection, defaults ConnectionDefaults, + ipv6Supported bool, randSource rand.Source) ( connection models.Connection, err error) { servers, err := storage.FilterServers(provider, selection) @@ -47,8 +48,7 @@ func GetConnection(provider string, connections := make([]models.Connection, 0, len(servers)) for _, server := range servers { for _, ip := range server.IPs { - if ip.To4() == nil { - // do not use IPv6 connections for now + if !ipv6Supported && ip.To4() == nil { continue } diff --git a/internal/provider/utils/connection_test.go b/internal/provider/utils/connection_test.go index d149f41d..e1530162 100644 --- a/internal/provider/utils/connection_test.go +++ b/internal/provider/utils/connection_test.go @@ -27,6 +27,7 @@ func Test_GetConnection(t *testing.T) { filterError error serverSelection settings.ServerSelection defaults ConnectionDefaults + ipv6Supported bool randSource rand.Source connection models.Connection errWrapped error @@ -122,6 +123,29 @@ func Test_GetConnection(t *testing.T) { Port: 1194, }, }, + "server with IPv4 and IPv6 and ipv6 supported": { + filteredServers: []models.Server{ + { + VPN: vpn.OpenVPN, + UDP: true, + IPs: []net.IP{ + net.IPv6zero, + net.IPv4(1, 1, 1, 1), + }, + }, + }, + serverSelection: settings.ServerSelection{}. + WithDefaults(providers.Mullvad), + defaults: NewConnectionDefaults(443, 1194, 58820), + ipv6Supported: true, + randSource: rand.NewSource(0), + connection: models.Connection{ + Type: vpn.OpenVPN, + IP: net.IPv6zero, + Protocol: constants.UDP, + Port: 1194, + }, + }, "mixed servers": { filteredServers: []models.Server{ { @@ -172,7 +196,7 @@ func Test_GetConnection(t *testing.T) { Return(testCase.filteredServers, testCase.filterError) connection, err := GetConnection(testCase.provider, storage, - testCase.serverSelection, testCase.defaults, + testCase.serverSelection, testCase.defaults, testCase.ipv6Supported, testCase.randSource) assert.Equal(t, testCase.connection, connection) diff --git a/internal/provider/vpnsecure/connection.go b/internal/provider/vpnsecure/connection.go index d4ee645e..2eae481c 100644 --- a/internal/provider/vpnsecure/connection.go +++ b/internal/provider/vpnsecure/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(110, 1282, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/vpnunlimited/connection.go b/internal/provider/vpnunlimited/connection.go index d628725e..fad54c4b 100644 --- a/internal/provider/vpnunlimited/connection.go +++ b/internal/provider/vpnunlimited/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/vyprvpn/connection.go b/internal/provider/vyprvpn/connection.go index 7d69b7de..9785dfc5 100644 --- a/internal/provider/vyprvpn/connection.go +++ b/internal/provider/vyprvpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(0, 443, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/wevpn/connection.go b/internal/provider/wevpn/connection.go index d8e567a8..081ba539 100644 --- a/internal/provider/wevpn/connection.go +++ b/internal/provider/wevpn/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(1195, 1194, 0) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/wevpn/connection_test.go b/internal/provider/wevpn/connection_test.go index 02253b67..9e9c2b8e 100644 --- a/internal/provider/wevpn/connection_test.go +++ b/internal/provider/wevpn/connection_test.go @@ -28,6 +28,7 @@ func Test_Provider_GetConnection(t *testing.T) { filteredServers []models.Server storageErr error selection settings.ServerSelection + ipv6Supported bool connection models.Connection errWrapped error errMessage string @@ -98,12 +99,12 @@ func Test_Provider_GetConnection(t *testing.T) { if testCase.panicMessage != "" { assert.PanicsWithValue(t, testCase.panicMessage, func() { - _, _ = provider.GetConnection(testCase.selection) + _, _ = provider.GetConnection(testCase.selection, testCase.ipv6Supported) }) return } - connection, err := provider.GetConnection(testCase.selection) + connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported) assert.ErrorIs(t, err, testCase.errWrapped) if testCase.errWrapped != nil { diff --git a/internal/provider/windscribe/connection.go b/internal/provider/windscribe/connection.go index ff5344d1..d8319ad4 100644 --- a/internal/provider/windscribe/connection.go +++ b/internal/provider/windscribe/connection.go @@ -6,9 +6,9 @@ import ( "github.com/qdm12/gluetun/internal/provider/utils" ) -func (p *Provider) GetConnection(selection settings.ServerSelection) ( +func (p *Provider) GetConnection(selection settings.ServerSelection, ipv6Supported bool) ( connection models.Connection, err error) { defaults := utils.NewConnectionDefaults(443, 1194, 1194) //nolint:gomnd return utils.GetConnection(p.Name(), - p.storage, selection, defaults, p.randSource) + p.storage, selection, defaults, ipv6Supported, p.randSource) } diff --git a/internal/provider/windscribe/connection_test.go b/internal/provider/windscribe/connection_test.go index 9c9e193d..fad338bd 100644 --- a/internal/provider/windscribe/connection_test.go +++ b/internal/provider/windscribe/connection_test.go @@ -29,6 +29,7 @@ func Test_Provider_GetConnection(t *testing.T) { filteredServers []models.Server storageErr error selection settings.ServerSelection + ipv6Supported bool connection models.Connection errWrapped error errMessage string @@ -105,12 +106,12 @@ func Test_Provider_GetConnection(t *testing.T) { if testCase.panicMessage != "" { assert.PanicsWithValue(t, testCase.panicMessage, func() { - _, _ = provider.GetConnection(testCase.selection) + _, _ = provider.GetConnection(testCase.selection, testCase.ipv6Supported) }) return } - connection, err := provider.GetConnection(testCase.selection) + connection, err := provider.GetConnection(testCase.selection, testCase.ipv6Supported) assert.ErrorIs(t, err, testCase.errWrapped) if testCase.errWrapped != nil { diff --git a/internal/vpn/openvpn.go b/internal/vpn/openvpn.go index cd7f3440..286c4a62 100644 --- a/internal/vpn/openvpn.go +++ b/internal/vpn/openvpn.go @@ -16,7 +16,7 @@ func setupOpenVPN(ctx context.Context, fw Firewall, openvpnConf OpenVPN, providerConf provider.Provider, settings settings.VPN, ipv6Supported bool, starter command.Starter, logger openvpn.Logger) (runner *openvpn.Runner, serverName string, err error) { - connection, err := providerConf.GetConnection(settings.Provider.ServerSelection) + connection, err := providerConf.GetConnection(settings.Provider.ServerSelection, ipv6Supported) if err != nil { return nil, "", fmt.Errorf("failed finding a valid server connection: %w", err) } diff --git a/internal/vpn/wireguard.go b/internal/vpn/wireguard.go index c9fd5418..ef71c9cd 100644 --- a/internal/vpn/wireguard.go +++ b/internal/vpn/wireguard.go @@ -16,7 +16,7 @@ func setupWireguard(ctx context.Context, netlinker NetLinker, fw Firewall, providerConf provider.Provider, settings settings.VPN, ipv6Supported bool, logger wireguard.Logger) ( wireguarder *wireguard.Wireguard, serverName string, err error) { - connection, err := providerConf.GetConnection(settings.Provider.ServerSelection) + connection, err := providerConf.GetConnection(settings.Provider.ServerSelection, ipv6Supported) if err != nil { return nil, "", fmt.Errorf("failed finding a VPN server: %w", err) }