Skip to content

Commit

Permalink
add socksopt rxtxbuf for freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokangwang committed Jan 23, 2022
1 parent 1a00452 commit 16a44f6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions transport/internet/sockopt_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
}
}

if config.SocketTxBufSize != 0 {
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)
}
}

if config.SocketRxBufSize != 0 {
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 nil
}

Expand Down Expand Up @@ -74,6 +86,17 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
}
}

if config.SocketTxBufSize != 0 {
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)
}
}

if config.SocketRxBufSize != 0 {
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 nil
}

Expand Down

0 comments on commit 16a44f6

Please sign in to comment.