Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skipping IPv6 server IPs via VPN_IPV6_SERVER #2557

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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