Maint: rename utility names to be Openvpn specific
- GetTargetIPConnection to GetTargetIPOpenVPNConnection - PickRandomConnection to PickRandomOpenVPNConnection
This commit is contained in:
@@ -33,8 +33,8 @@ func (c *Cyberghost) GetOpenVPNConnection(selection configuration.ServerSelectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, c.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, c.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ func (f *Fastestvpn) GetOpenVPNConnection(selection configuration.ServerSelectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, f.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, f.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func (h *HideMyAss) GetOpenVPNConnection(selection configuration.ServerSelection
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, h.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, h.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func (i *Ipvanish) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, i.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, i.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func (i *Ivpn) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, i.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, i.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func (m *Mullvad) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, m.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, m.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ func (n *Nordvpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, n.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, n.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ func (p *Privado) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ func (p *PIA) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
connection, err = utils.GetTargetIPConnection(connections, selection.TargetIP)
|
connection, err = utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
} else {
|
} else {
|
||||||
connection, err = utils.PickRandomConnection(connections, p.randSource), nil
|
connection, err = utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (p *Privatevpn) GetOpenVPNConnection(selection configuration.ServerSelectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (p *Protonvpn) GetOpenVPNConnection(selection configuration.ServerSelection
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (p *Purevpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (s *Surfshark) GetOpenVPNConnection(selection configuration.ServerSelection
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, s.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, s.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ func (t *Torguard) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, t.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, t.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/models"
|
"github.com/qdm12/gluetun/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PickRandomConnection(connections []models.OpenVPNConnection,
|
func PickRandomOpenVPNConnection(connections []models.OpenVPNConnection,
|
||||||
source rand.Source) models.OpenVPNConnection {
|
source rand.Source) models.OpenVPNConnection {
|
||||||
return connections[rand.New(source).Intn(len(connections))] //nolint:gosec
|
return connections[rand.New(source).Intn(len(connections))] //nolint:gosec
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_PickRandomConnection(t *testing.T) {
|
func Test_PickRandomOpenVPNConnection(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
connections := []models.OpenVPNConnection{
|
connections := []models.OpenVPNConnection{
|
||||||
{Port: 1}, {Port: 2}, {Port: 3}, {Port: 4},
|
{Port: 1}, {Port: 2}, {Port: 3}, {Port: 4},
|
||||||
}
|
}
|
||||||
source := rand.NewSource(0)
|
source := rand.NewSource(0)
|
||||||
|
|
||||||
connection := PickRandomConnection(connections, source)
|
connection := PickRandomOpenVPNConnection(connections, source)
|
||||||
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
||||||
|
|
||||||
connection = PickRandomConnection(connections, source)
|
connection = PickRandomOpenVPNConnection(connections, source)
|
||||||
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
||||||
|
|
||||||
connection = PickRandomConnection(connections, source)
|
connection = PickRandomOpenVPNConnection(connections, source)
|
||||||
assert.Equal(t, models.OpenVPNConnection{Port: 2}, connection)
|
assert.Equal(t, models.OpenVPNConnection{Port: 2}, connection)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
var ErrTargetIPNotFound = errors.New("target IP address not found")
|
var ErrTargetIPNotFound = errors.New("target IP address not found")
|
||||||
|
|
||||||
func GetTargetIPConnection(connections []models.OpenVPNConnection,
|
func GetTargetIPOpenVPNConnection(connections []models.OpenVPNConnection,
|
||||||
targetIP net.IP) (connection models.OpenVPNConnection, err error) {
|
targetIP net.IP) (connection models.OpenVPNConnection, err error) {
|
||||||
for _, connection := range connections {
|
for _, connection := range connections {
|
||||||
if targetIP.Equal(connection.IP) {
|
if targetIP.Equal(connection.IP) {
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ func (p *Provider) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func (v *Vyprvpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, v.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, v.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ func (w *Windscribe) GetOpenVPNConnection(selection configuration.ServerSelectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
if selection.TargetIP != nil {
|
||||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.PickRandomConnection(connections, w.randSource), nil
|
return utils.PickRandomOpenVPNConnection(connections, w.randSource), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user