diff --git a/internal/client/piper.go b/internal/client/piper.go index 6c62eae..fa8d01b 100644 --- a/internal/client/piper.go +++ b/internal/client/piper.go @@ -138,12 +138,12 @@ func RouteTCP(localConfig localConnConfig, newSeshFunc func() *mux.Session) { } go func() { if _, err := common.Copy(localConn, stream, 0); err != nil { - log.Debugf("copying stream to proxy client: %v", err) + log.Tracef("copying stream to proxy client: %v", err) } }() //util.Pipe(stream, localConn, localConfig.Timeout) if _, err = common.Copy(stream, localConn, localConfig.Timeout); err != nil { - log.Debugf("copying proxy client to stream: %v", err) + log.Tracef("copying proxy client to stream: %v", err) } }() } diff --git a/internal/common/copy.go b/internal/common/copy.go index cc6e4b2..921d921 100644 --- a/internal/common/copy.go +++ b/internal/common/copy.go @@ -69,6 +69,7 @@ func Copy(dst net.Conn, src net.Conn, srcReadTimeout time.Duration) (written int //} for { if srcReadTimeout != 0 { + // TODO: don't rely on setreaddeadline err = src.SetReadDeadline(time.Now().Add(srcReadTimeout)) if err != nil { break @@ -96,5 +97,7 @@ func Copy(dst net.Conn, src net.Conn, srcReadTimeout time.Duration) (written int break } } + src.Close() + dst.Close() return written, err } diff --git a/internal/multiplex/stream.go b/internal/multiplex/stream.go index 0e712cb..14a7728 100644 --- a/internal/multiplex/stream.go +++ b/internal/multiplex/stream.go @@ -101,6 +101,7 @@ func (s *Stream) Write(in []byte) (n int, err error) { if len(in) <= maxDataLen { payload = in } else { + //TODO: short write isn't the correct behaviour payload = in[:maxDataLen] } diff --git a/internal/server/dispatcher.go b/internal/server/dispatcher.go index 989e750..dbe45e6 100644 --- a/internal/server/dispatcher.go +++ b/internal/server/dispatcher.go @@ -175,12 +175,12 @@ func DispatchConnection(conn net.Conn, sta *State) { go func() { if _, err := common.Copy(localConn, newStream, sta.Timeout); err != nil { - log.Debugf("copying stream to proxy client: %v", err) + log.Tracef("copying stream to proxy client: %v", err) } }() go func() { if _, err := common.Copy(newStream, localConn, 0); err != nil { - log.Debugf("copying proxy client to stream: %v", err) + log.Tracef("copying proxy client to stream: %v", err) } }() }