mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-18 01:58:41 +00:00
fix udp original destination on windows
This commit is contained in:
parent
e9b3c53a0d
commit
d5c53b1ddd
5 changed files with 95 additions and 4 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -142,6 +143,15 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||
}
|
||||
}
|
||||
|
||||
if config.ReceiveOriginalDestAddress && isUDPSocket(network) {
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, windows.IP_PKTINFO, 1); err != nil {
|
||||
return errors.New("failed to set IP_PKTINFO").Base(err)
|
||||
}
|
||||
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, windows.IPV6_PKTINFO, 1); err != nil {
|
||||
return errors.New("failed to set IPV6_PKTINFO").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(config.CustomSockopt) > 0 {
|
||||
for _, custom := range config.CustomSockopt {
|
||||
if custom.System != "" && custom.System != runtime.GOOS {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue