mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-09 23:26:39 +00:00
Sockopt: Allow listen v6only
work for Windows & Darwin (#4571)
Completes https://github.com/XTLS/Xray-core/pull/1677 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
parent
63eb0539b3
commit
2abeda9c42
@ -200,6 +200,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.V6Only {
|
||||||
|
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1); err != nil {
|
||||||
|
return errors.New("failed to set IPV6_V6ONLY").Base(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ const (
|
|||||||
IPV6_UNICAST_IF = 31
|
IPV6_UNICAST_IF = 31
|
||||||
IP_MULTICAST_IF = 9
|
IP_MULTICAST_IF = 9
|
||||||
IPV6_MULTICAST_IF = 9
|
IPV6_MULTICAST_IF = 9
|
||||||
|
IPV6_V6ONLY = 27
|
||||||
)
|
)
|
||||||
|
|
||||||
func setTFO(fd syscall.Handle, tfo int) error {
|
func setTFO(fd syscall.Handle, tfo int) error {
|
||||||
@ -90,6 +91,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.V6Only {
|
||||||
|
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_V6ONLY, 1); err != nil {
|
||||||
|
return errors.New("failed to set IPV6_V6ONLY").Base(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user