mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
feat(vpn): auto detection of IPv6 support
- `OPENVPN_IPV6` removed - Affects OpenVPN - Use the same mechanism for OpenVPN and Wireguard - Check only once at program start since this is unlikely to change at runtime - Log if IPv6 is supported - Remove `IPv6` boolean from settings structs - Move IPv6 detection as a method on NetLinker
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package netlink
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
func (n *NetLink) IsIPv6Supported() (supported bool, err error) {
|
||||
links, err := n.LinkList()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("listing links: %w", err)
|
||||
}
|
||||
|
||||
for _, link := range links {
|
||||
routes, err := n.RouteList(link, netlink.FAMILY_V6)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("listing IPv6 routes for link %s: %w",
|
||||
link.Attrs().Name, err)
|
||||
}
|
||||
|
||||
if len(routes) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
Reference in New Issue
Block a user