cmd/tsconnect: add error callback for SSH sessions

We were just logging them to the console, which is useful for debugging,
but we may want to show them in the UI too.

Updates tailscale/corp#6939

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita 2022-09-20 18:10:37 -07:00 committed by Mihai Parparita
parent e9b98dd2e1
commit a7a0baf6b9
2 changed files with 3 additions and 2 deletions

View File

@ -46,7 +46,7 @@ function SSHSession({
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (ref.current) {
runSSHSession(ref.current, def, ipn, onDone)
runSSHSession(ref.current, def, ipn, onDone, (err) => console.error(err))
}
}, [ref])

View File

@ -14,6 +14,7 @@ export function runSSHSession(
def: SSHSessionDef,
ipn: IPN,
onDone: () => void,
onError?: (err: string) => void,
terminalOptions?: ITerminalOptions
) {
const parentWindow = termContainerNode.ownerDocument.defaultView ?? window
@ -48,7 +49,7 @@ export function runSSHSession(
term.write(input)
},
writeErrorFn(err) {
console.error(err)
onError?.(err)
term.write(err)
},
setReadFn(hook) {