From 391c017956691d94bfb039a5aac15814e84bb4e1 Mon Sep 17 00:00:00 2001 From: notsure2 Date: Sun, 11 Jun 2023 01:40:03 +0300 Subject: [PATCH] Fix failing unit test due to the connection not being a tcp connection in tests. --- internal/client/connector.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/client/connector.go b/internal/client/connector.go index f3b41c0..1b283d8 100644 --- a/internal/client/connector.go +++ b/internal/client/connector.go @@ -32,20 +32,22 @@ func MakeSession(connConfig RemoteConnConfig, authInfo AuthInfo, dialer common.D goto makeconn } - tcpConn := remoteConn.(*net.TCPConn) - syscallConn, err := tcpConn.SyscallConn() - if err != nil { - panic(err) - } - - err = syscallConn.Control(func(fd uintptr) { - err = syscall.SetsockoptInt(common.Platformfd(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1) + tcpConn, ok := remoteConn.(*net.TCPConn) + if ok { + syscallConn, err := tcpConn.SyscallConn() if err != nil { - log.Errorf("setsocketopt TCP_NODELAY: %s\n", err) + panic(err) + } + + err = syscallConn.Control(func(fd uintptr) { + err = syscall.SetsockoptInt(common.Platformfd(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1) + if err != nil { + log.Errorf("setsocketopt TCP_NODELAY: %s\n", err) + } + }) + if err != nil { + panic(err) } - }) - if err != nil { - panic(err) } transportConn := connConfig.TransportMaker()