fix: connect to stdout fd after starting an ssh shell

this avoids a race condition that would happen if the goroutine tried to read a
file descriptor that wasn't open properly and would lose frame delivery
This commit is contained in:
Aarnav Tale
2025-05-31 12:57:18 -04:00
parent cb32637938
commit a0a80852eb
+3 -3
View File
@@ -120,9 +120,6 @@ func StartWebSSH(agent *tsnet.TSAgent, params SSHConnectPayload) {
}
}()
// This spawns 2 goroutins for stdout and stderr
dispatchSSHStdout(params.SessionId, ctx.Stdout, ctx.Stderr)
// Spin up a shell and wait for the pty to terminate
err = sess.Shell()
if err != nil {
@@ -131,6 +128,9 @@ func StartWebSSH(agent *tsnet.TSAgent, params SSHConnectPayload) {
return
}
// This spawns 2 goroutins for stdout and stderr
dispatchSSHStdout(params.SessionId, ctx.Stdout, ctx.Stderr)
log.Info("Opened an SSH PTY for %s", params.SessionId)
sess.Wait()
sess.Close()