From 971a8dadfcfc654a38b9c8d6b2050155d71c9ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 20 Mar 2025 17:44:02 +0000 Subject: [PATCH] Fix network stack --- transport/internet/system_dialer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 52b1e830..4af666c5 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -73,7 +73,14 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne return nil, err } sys.Control(func(fd uintptr) { - if err := applyOutboundSocketOptions("udp", dest.NetAddr(), fd, sockopt); err != nil { + // applyOutboundSocketOptions needs to netwotk with specified network stack(udp4/udp6) + var network string + if destAddr.IP.To4() != nil { + network = "udp4" + } else { + network = "udp6" + } + if err := applyOutboundSocketOptions(network, dest.NetAddr(), fd, sockopt); err != nil { errors.LogInfo(ctx, err, "failed to apply socket options") } })