Maint: rename utility names to be Openvpn specific
- GetTargetIPConnection to GetTargetIPOpenVPNConnection - PickRandomConnection to PickRandomOpenVPNConnection
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
func PickRandomConnection(connections []models.OpenVPNConnection,
|
||||
func PickRandomOpenVPNConnection(connections []models.OpenVPNConnection,
|
||||
source rand.Source) models.OpenVPNConnection {
|
||||
return connections[rand.New(source).Intn(len(connections))] //nolint:gosec
|
||||
}
|
||||
|
||||
@@ -8,19 +8,19 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_PickRandomConnection(t *testing.T) {
|
||||
func Test_PickRandomOpenVPNConnection(t *testing.T) {
|
||||
t.Parallel()
|
||||
connections := []models.OpenVPNConnection{
|
||||
{Port: 1}, {Port: 2}, {Port: 3}, {Port: 4},
|
||||
}
|
||||
source := rand.NewSource(0)
|
||||
|
||||
connection := PickRandomConnection(connections, source)
|
||||
connection := PickRandomOpenVPNConnection(connections, source)
|
||||
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
||||
|
||||
connection = PickRandomConnection(connections, source)
|
||||
connection = PickRandomOpenVPNConnection(connections, source)
|
||||
assert.Equal(t, models.OpenVPNConnection{Port: 3}, connection)
|
||||
|
||||
connection = PickRandomConnection(connections, source)
|
||||
connection = PickRandomOpenVPNConnection(connections, source)
|
||||
assert.Equal(t, models.OpenVPNConnection{Port: 2}, connection)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
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) {
|
||||
for _, connection := range connections {
|
||||
if targetIP.Equal(connection.IP) {
|
||||
|
||||
Reference in New Issue
Block a user