1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 15:36:41 -05:00

rewrite sockopt rxtx buf size message for darwin, freebsd

This commit is contained in:
Shelikhoo 2022-01-16 22:52:31 +00:00 committed by Xiaokang Wang (Shelikhoo)
parent 16a44f65be
commit 547b4fb49b
2 changed files with 6 additions and 6 deletions

View File

@ -44,13 +44,13 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
if config.SocketTxBufSize != 0 { if config.SocketTxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
return newError("failed to set SO_SNDBUF/SO_SNDBUFFORCE").Base(err) return newError("failed to set SO_SNDBUF").Base(err)
} }
} }
if config.SocketRxBufSize != 0 { if config.SocketRxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil {
return newError("failed to set SO_RCVBUF/SO_RCVBUFFORCE").Base(err) return newError("failed to set SO_RCVBUF").Base(err)
} }
} }

View File

@ -174,13 +174,13 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
if config.SocketTxBufSize != 0 { if config.SocketTxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
return newError("failed to set SO_SNDBUF/SO_SNDBUFFORCE").Base(err) return newError("failed to set SO_SNDBUF").Base(err)
} }
} }
if config.SocketRxBufSize != 0 { if config.SocketRxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil {
return newError("failed to set SO_RCVBUF/SO_RCVBUFFORCE").Base(err) return newError("failed to set SO_RCVBUF").Base(err)
} }
} }
@ -231,13 +231,13 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
if config.SocketTxBufSize != 0 { if config.SocketTxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, int(config.SocketTxBufSize)); err != nil {
return newError("failed to set SO_SNDBUF/SO_SNDBUFFORCE").Base(err) return newError("failed to set SO_SNDBUF").Base(err)
} }
} }
if config.SocketRxBufSize != 0 { if config.SocketRxBufSize != 0 {
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil { if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, int(config.SocketRxBufSize)); err != nil {
return newError("failed to set SO_RCVBUF/SO_RCVBUFFORCE").Base(err) return newError("failed to set SO_RCVBUF").Base(err)
} }
} }