feat(pmtud/tcp): support mixed IPv4 and IPv6 TCP servers

- Add default cloudflare and google tls ipv6 servers to default tcp servers
- update integration test to try against both ipv4 and ipv6 servers
This commit is contained in:
Quentin McGaw
2026-02-19 17:11:16 +00:00
parent 1c43a045d1
commit c6b211ef9b
15 changed files with 175 additions and 70 deletions
+7 -8
View File
@@ -33,17 +33,14 @@ func PathMTUDiscover(ctx context.Context, dsts []netip.AddrPort,
minMTU, maxPossibleMTU uint32, tryTimeout time.Duration,
firewall Firewall, logger Logger,
) (mtu uint32, err error) {
family := constants.AF_INET
if dsts[0].Addr().Is6() {
family = constants.AF_INET6
}
fd, stop, err := startRawSocket(family, excludeMark)
families := ip.GetFamilies(dsts)
familyToFD, stop, err := startRawSockets(families, excludeMark)
if err != nil {
return 0, fmt.Errorf("starting raw socket: %w", err)
return 0, fmt.Errorf("starting raw sockets: %w", err)
}
defer stop()
tracker := newTracker(fd, family == constants.AF_INET)
tracker := newTracker(familyToFD)
trackerCtx, trackerCancel := context.WithCancel(ctx)
defer trackerCancel()
@@ -62,7 +59,7 @@ func PathMTUDiscover(ctx context.Context, dsts []netip.AddrPort,
mssCtx, mssCancel := context.WithTimeout(ctx, tryTimeout)
defer mssCancel()
go func() {
dst, mss, err := findHighestMSSDestination(mssCtx, fd, dsts, excludeMark,
dst, mss, err := findHighestMSSDestination(mssCtx, familyToFD, dsts, excludeMark,
maxPossibleMTU, tryTimeout, tracker, firewall, logger)
mssResultCh <- mssResult{dst: dst, mss: mss, err: err}
}()
@@ -83,6 +80,8 @@ func PathMTUDiscover(ctx context.Context, dsts []netip.AddrPort,
maxPossibleMTU = ipHeaderLength + constants.BaseTCPHeaderLength + result.mss
}
fd := familyToFD[ip.GetFamily(highestMSSDst)]
type pmtudResult struct {
mtu uint32
err error