Skip to content

Commit

Permalink
perf(conns): improve data transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Apr 16, 2018
1 parent ad6fe5d commit b6c2592
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions server/ssh_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,24 @@ func handleForwardTCPIP(client *Client, bindinfo *bindInfo, lconn net.Conn) {
log.Printf("[%s] Channel opened for client", client.ID)
go ssh.DiscardRequests(requests)

go io.Copy(c, lconn)
go io.Copy(lconn, c)
go handleForwardTCPIPTransfer(c, lconn)
}

func handleForwardTCPIPTransfer(c ssh.Channel, lconn net.Conn) {
defer lconn.Close()
done := make(chan bool)

go func() {
io.Copy(c, lconn)
done <- true
}()

go func() {
io.Copy(lconn, c)
done <- true
}()

<-done
}

func handleForward(client *Client, req *ssh.Request) (net.Listener, *bindInfo, error) {
Expand Down

0 comments on commit b6c2592

Please sign in to comment.