hotfix(pmtud): detect IPv6 usage in VPN connection

This commit is contained in:
Quentin McGaw
2026-05-09 14:40:04 +00:00
parent 445f99d9dc
commit 5b01324d5f
7 changed files with 69 additions and 24 deletions
+1 -8
View File
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"net/netip"
"strings"
"github.com/jsimonetti/rtnetlink"
"github.com/qdm12/gluetun/internal/pmtud/constants"
@@ -28,10 +27,7 @@ func SrcAddr(dst netip.AddrPort, proto int) (src netip.AddrPort, cleanup func(),
return netip.AddrPortFrom(srcAddr, srcPort), cleanup, nil
}
var (
errNoRoute = errors.New("no route to destination")
ErrNetworkUnreachable = errors.New("network unreachable")
)
var errNoRoute = errors.New("no route to destination")
func srcIP(dst netip.Addr) (netip.Addr, error) {
conn, err := rtnetlink.Dial(nil)
@@ -54,9 +50,6 @@ func srcIP(dst netip.Addr) (netip.Addr, error) {
}
messages, err := conn.Route.Get(requestMessage)
if err != nil {
if strings.Contains(err.Error(), "network is unreachable") {
err = ErrNetworkUnreachable
}
return netip.Addr{}, fmt.Errorf("getting routes to %s: %w", dst, err)
}