mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
add socksopt rxtxbuf for windows
This commit is contained in:
parent
eb0b52fdfa
commit
7dc8559f1c
@ -1,6 +1,9 @@
|
||||
package internet
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
TCP_FASTOPEN = 15 // nolint: revive,stylecheck
|
||||
@ -32,6 +35,18 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
||||
}
|
||||
}
|
||||
|
||||
if config.SocketTxBufSize != 0 {
|
||||
if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
|
||||
return newError("failed to set SO_SNDBUF").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.SocketRxBufSize != 0 {
|
||||
if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_RCVBUF, int(config.SocketTxBufSize)); err != nil {
|
||||
return newError("failed to set SO_RCVBUF").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -47,6 +62,18 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
||||
}
|
||||
}
|
||||
|
||||
if config.SocketTxBufSize != 0 {
|
||||
if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
|
||||
return newError("failed to set SO_SNDBUF").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.SocketRxBufSize != 0 {
|
||||
if err := windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_RCVBUF, int(config.SocketTxBufSize)); err != nil {
|
||||
return newError("failed to set SO_RCVBUF").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user