Skip to content

Commit 1bc508b

Browse files
committed
[ssh-gateway] fix missing output when running simple command
1 parent 8c6d8e2 commit 1bc508b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

components/ws-proxy/pkg/sshproxy/forward.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *Server) ChannelForward(ctx context.Context, session *Session, targetCon
2020
targetChan, targetReqs, err := targetConn.OpenChannel(originChannel.ChannelType(), originChannel.ExtraData())
2121
if err != nil {
2222
log.WithFields(log.OWI("", session.WorkspaceID, session.InstanceID)).Error("open target channel error")
23-
originChannel.Reject(ssh.ConnectionFailed, "open target channel error")
23+
_ = originChannel.Reject(ssh.ConnectionFailed, "open target channel error")
2424
return
2525
}
2626
defer targetChan.Close()
@@ -54,21 +54,21 @@ func (s *Server) ChannelForward(ctx context.Context, session *Session, targetCon
5454
}()
5555

5656
go func() {
57-
io.Copy(targetChan, originChan)
58-
targetChan.CloseWrite()
57+
_, _ = io.Copy(targetChan, originChan)
58+
_ = targetChan.Close()
5959
}()
6060

6161
go func() {
62-
io.Copy(originChan, targetChan)
63-
originChan.CloseWrite()
62+
_, _ = io.Copy(originChan, targetChan)
63+
_ = originChan.Close()
6464
}()
6565

6666
go func() {
67-
io.Copy(targetChan.Stderr(), originChan.Stderr())
67+
_, _ = io.Copy(targetChan.Stderr(), originChan.Stderr())
6868
}()
6969

7070
go func() {
71-
io.Copy(originChan.Stderr(), targetChan.Stderr())
71+
_, _ = io.Copy(originChan.Stderr(), targetChan.Stderr())
7272
}()
7373

7474
wg := sync.WaitGroup{}
@@ -78,7 +78,6 @@ func (s *Server) ChannelForward(ctx context.Context, session *Session, targetCon
7878
select {
7979
case req, ok := <-sourceReqs:
8080
if !ok {
81-
targetChan.Close()
8281
return
8382
}
8483
b, err := targetChan.SendRequest(req.Type, req.WantReply, req.Payload)

0 commit comments

Comments
 (0)