Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/provider/utils/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package utils
import (
"fmt"
"math/rand"
"os"
"strings"

"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/vpn"
Expand Down Expand Up @@ -38,6 +40,10 @@ func GetConnection(provider string,
randSource rand.Source) (
connection models.Connection, err error,
) {
// Read the VPN_IPV6_SERVER environment variable
vpnIPv6Server := os.Getenv("VPN_IPV6_SERVER")
skipIPv6Servers := strings.EqualFold(vpnIPv6Server, "off")

servers, err := storage.FilterServers(provider, selection)
if err != nil {
return connection, fmt.Errorf("filtering servers: %w", err)
Expand All @@ -50,6 +56,10 @@ func GetConnection(provider string,
connections := make([]models.Connection, 0, len(servers))
for _, server := range servers {
for _, ip := range server.IPs {
if skipIPv6Servers && ip.Is6() {
continue
}

if !ipv6Supported && ip.Is6() {
continue
}
Expand Down