Skip to content

Commit

Permalink
Fix bug with unclosed ssh connection (#13)
Browse files Browse the repository at this point in the history
Often there were unclosed SSH connections, later as it turned out, this was due to the fact that only those connections were added to the closures through which it was possible to establish a TCP connection.
  • Loading branch information
vl4deee11 committed Sep 10, 2021
1 parent af50be1 commit 6539d4e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ssh_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ func (tunnel *SSHTunnel) forward(localConn net.Conn) {
return
}
tunnel.logf("connected to %s (1 of 2)\n", tunnel.Server.String())
tunnel.SvrConns = append(tunnel.SvrConns, serverConn)

remoteConn, err := serverConn.Dial("tcp", tunnel.Remote.String())
if err != nil {
tunnel.logf("remote dial error: %s", err)
return
}
tunnel.Conns = append(tunnel.Conns, remoteConn)
tunnel.SvrConns = append(tunnel.SvrConns, serverConn)
tunnel.logf("connected to %s (2 of 2)\n", tunnel.Remote.String())
copyConn := func(writer, reader net.Conn) {
_, err := io.Copy(writer, reader)
Expand Down

0 comments on commit 6539d4e

Please sign in to comment.