Better way to discard requests & close channel/conn on disconnects
This commit is contained in:
parent
e373c91f8b
commit
6d5726d78a
2 changed files with 3 additions and 16 deletions
15
client.go
15
client.go
|
|
@ -96,7 +96,7 @@ func (c *Client) openStreamingChannel(ctx context.Context, streamName, condition
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("error opening ssh channel for transport: %v", err)
|
||||
}
|
||||
go c.processChannelRequests(ctx, reqs)
|
||||
go ssh.DiscardRequests(reqs)
|
||||
|
||||
requestType := fmt.Sprintf("stream-transport-%s", streamID)
|
||||
_, err = channel.SendRequest(requestType, true, nil)
|
||||
|
|
@ -106,16 +106,3 @@ func (c *Client) openStreamingChannel(ctx context.Context, streamName, condition
|
|||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
func (c *Client) processChannelRequests(ctx context.Context, reqs <-chan *ssh.Request) {
|
||||
for {
|
||||
select {
|
||||
case req := <-reqs:
|
||||
if req != nil {
|
||||
// TODO(josebalius): Handle
|
||||
}
|
||||
case <-ctx.Done():
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ func (l *LocalPortForwarder) handleConnection(ctx context.Context, conn net.Conn
|
|||
copyConn := func(writer io.Writer, reader io.Reader) {
|
||||
_, err := io.Copy(writer, reader)
|
||||
if err != nil {
|
||||
log.Println("errrrr copyConn")
|
||||
log.Println(err) //TODO(josebalius): handle this somehow
|
||||
channel.Close()
|
||||
conn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue