Fix: buffer should be set even in unordered mode because in the end it's tcp

This commit is contained in:
notsure2 2023-12-21 23:28:57 +02:00
parent 18355d06ce
commit c3cde8d8af
1 changed files with 19 additions and 21 deletions

View File

@ -155,30 +155,28 @@ func main() {
var seshMaker func() *mux.Session
control := func(network string, address string, rawConn syscall.RawConn) error {
if !authInfo.Unordered {
sendBufferSize := remoteConfig.TcpSendBuffer
receiveBufferSize := remoteConfig.TcpReceiveBuffer
sendBufferSize := remoteConfig.TcpSendBuffer
receiveBufferSize := remoteConfig.TcpReceiveBuffer
err := rawConn.Control(func(fd uintptr) {
if sendBufferSize > 0 {
log.Debugf("Setting remote connection tcp send buffer: %d", sendBufferSize)
err := syscall.SetsockoptInt(common.Platformfd(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, sendBufferSize)
if err != nil {
log.Errorf("setsocketopt SO_SNDBUF: %s\n", err)
}
err := rawConn.Control(func(fd uintptr) {
if sendBufferSize > 0 {
log.Debugf("Setting remote connection tcp send buffer: %d", sendBufferSize)
err := syscall.SetsockoptInt(common.Platformfd(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, sendBufferSize)
if err != nil {
log.Errorf("setsocketopt SO_SNDBUF: %s\n", err)
}
if receiveBufferSize > 0 {
log.Debugf("Setting remote connection tcp receive buffer: %d", receiveBufferSize)
err = syscall.SetsockoptInt(common.Platformfd(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, receiveBufferSize)
if err != nil {
log.Errorf("setsocketopt SO_RCVBUF: %s\n", err)
}
}
})
if err != nil {
panic(err)
}
if receiveBufferSize > 0 {
log.Debugf("Setting remote connection tcp receive buffer: %d", receiveBufferSize)
err = syscall.SetsockoptInt(common.Platformfd(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, receiveBufferSize)
if err != nil {
log.Errorf("setsocketopt SO_RCVBUF: %s\n", err)
}
}
})
if err != nil {
panic(err)
}
return protector(network, address, rawConn)