mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-01 19:26:39 +00:00
Sockopt: Fix Windows Multicast interface
bind (#4568)
https://github.com/XTLS/Xray-core/pull/4568#issuecomment-2763492336
This commit is contained in:
parent
1685c61e44
commit
52a2c63682
@ -13,6 +13,8 @@ const (
|
||||
TCP_FASTOPEN = 15
|
||||
IP_UNICAST_IF = 31
|
||||
IPV6_UNICAST_IF = 31
|
||||
IP_MULTICAST_IF = 9
|
||||
IPV6_MULTICAST_IF = 9
|
||||
)
|
||||
|
||||
func setTFO(fd syscall.Handle, tfo int) error {
|
||||
@ -41,10 +43,16 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_UNICAST_IF, int(idx)); err != nil {
|
||||
return errors.New("failed to set IP_UNICAST_IF").Base(err)
|
||||
}
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_MULTICAST_IF, int(idx)); err != nil {
|
||||
return errors.New("failed to set IP_MULTICAST_IF").Base(err)
|
||||
}
|
||||
} else {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_UNICAST_IF, inf.Index); err != nil {
|
||||
return errors.New("failed to set IPV6_UNICAST_IF").Base(err)
|
||||
}
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_MULTICAST_IF, inf.Index); err != nil {
|
||||
return errors.New("failed to set IPV6_MULTICAST_IF").Base(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user