mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-16 00:14:10 +02:00
hotfix(provider/utils): randomize pool of filterd servers to pick connections from
This commit is contained in:
@@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand/v2"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
@@ -44,6 +45,12 @@ func GetConnection(provider string,
|
|||||||
return connection, fmt.Errorf("filtering servers: %w", err)
|
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)
|
protocol := getProtocol(selection)
|
||||||
port := getPort(selection, defaults.OpenVPNTCPPort,
|
port := getPort(selection, defaults.OpenVPNTCPPort,
|
||||||
defaults.OpenVPNUDPPort, defaults.WireguardPort)
|
defaults.OpenVPNUDPPort, defaults.WireguardPort)
|
||||||
|
|||||||
Reference in New Issue
Block a user