Skip to content

Commit 26df32d

Browse files
committed
minor tweak
1 parent 70ca384 commit 26df32d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

dialer/sockopt_windows.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ func WithInterface(iface *net.Interface) SocketOption {
2525
err = bindSocketToInterface6(windows.Handle(fd), uint32(index))
2626
}
2727
if network == "udp6" {
28-
// The underlying IP net maybe IPv4 even if the `network` param is `udp6`,
29-
// so we should bind socket to interface4 at the same time.
30-
_ = bindSocketToInterface4(windows.Handle(fd), uint32(index))
28+
host, _, _ := net.SplitHostPort(address)
29+
if ip := net.ParseIP(host); ip == nil || ip.IsUnspecified() {
30+
// The underlying IP net maybe IPv4 even if the `network` param is
31+
// `udp6`, so we should bind socket to interface4 at the same time.
32+
_ = bindSocketToInterface4(windows.Handle(fd), uint32(index))
33+
}
3134
}
3235
return
3336
})

0 commit comments

Comments
 (0)