hotfix(provider/utils): randomize pool of filterd servers to pick connections from

This commit is contained in:
Quentin McGaw
2026-05-12 01:08:19 +00:00
parent 38cf094573
commit 3ca4b48887
+7
View File
@@ -2,6 +2,7 @@ package utils
import (
"fmt"
"math/rand/v2"
"slices"
"github.com/qdm12/gluetun/internal/configuration/settings"
@@ -44,6 +45,12 @@ func GetConnection(provider string,
return connection, fmt.Errorf("filtering servers: %w", err)
}
// Randomize order of the servers struct so the first connection to be picked
// won't always be the same one.
rand.Shuffle(len(servers), func(i, j int) {
servers[i], servers[j] = servers[j], servers[i]
})
protocol := getProtocol(selection)
port := getPort(selection, defaults.OpenVPNTCPPort,
defaults.OpenVPNUDPPort, defaults.WireguardPort)