mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-22 19:33:32 +02:00
Fix and simplify SockOpt in UDP
https://github.com/golang/go/issues/29277
This commit is contained in:
parent
a0f1e1f377
commit
3778a367c8
1 changed files with 4 additions and 6 deletions
|
@ -2,7 +2,6 @@ package internet
|
|||
|
||||
import (
|
||||
"context"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -67,17 +66,16 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if runtime.GOOS != "windows" && (sockopt != nil || len(d.controllers) > 0) {
|
||||
file, err := packetConn.(*net.UDPConn).File()
|
||||
if sockopt != nil {
|
||||
sys, err := packetConn.(*net.UDPConn).SyscallConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fd := file.Fd()
|
||||
if sockopt != nil {
|
||||
sys.Control(func(fd uintptr) {
|
||||
if err := applyOutboundSocketOptions("udp", dest.NetAddr(), fd, sockopt); err != nil {
|
||||
newError("failed to apply socket options").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return &PacketConnWrapper{
|
||||
Conn: packetConn,
|
||||
|
|
Loading…
Reference in a new issue