mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
feat(ipv6): prefer IPv6 endpoints when IPv6 is supported
This commit is contained in:
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants/vpn"
|
||||
@@ -75,5 +76,18 @@ func GetConnection(provider string,
|
||||
}
|
||||
}
|
||||
|
||||
slices.SortStableFunc(connections, func(a, b models.Connection) int {
|
||||
aIPv6 := a.IP.Is6()
|
||||
bIPv6 := b.IP.Is6()
|
||||
switch {
|
||||
case aIPv6 && !bIPv6:
|
||||
return -1
|
||||
case !aIPv6 && bIPv6:
|
||||
return 1
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
})
|
||||
|
||||
return pickConnection(connections, selection, connPicker)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user