From c3cde8d8af14e211487030f1797d0592488223de Mon Sep 17 00:00:00 2001 From: notsure2 Date: Thu, 21 Dec 2023 23:28:57 +0200 Subject: [PATCH] Fix: buffer should be set even in unordered mode because in the end it's tcp --- cmd/ck-client/ck-client.go | 40 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/cmd/ck-client/ck-client.go b/cmd/ck-client/ck-client.go index f28213d..90b67e2 100644 --- a/cmd/ck-client/ck-client.go +++ b/cmd/ck-client/ck-client.go @@ -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)