From a7a0baf6b9952d6528bf75c5c8618f9f49548ef2 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Tue, 20 Sep 2022 18:10:37 -0700 Subject: [PATCH] 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 --- cmd/tsconnect/src/app/ssh.tsx | 2 +- cmd/tsconnect/src/lib/ssh.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/tsconnect/src/app/ssh.tsx b/cmd/tsconnect/src/app/ssh.tsx index bd8ee4690..8048d9b2a 100644 --- a/cmd/tsconnect/src/app/ssh.tsx +++ b/cmd/tsconnect/src/app/ssh.tsx @@ -46,7 +46,7 @@ function SSHSession({ const ref = useRef(null) useEffect(() => { if (ref.current) { - runSSHSession(ref.current, def, ipn, onDone) + runSSHSession(ref.current, def, ipn, onDone, (err) => console.error(err)) } }, [ref]) diff --git a/cmd/tsconnect/src/lib/ssh.ts b/cmd/tsconnect/src/lib/ssh.ts index f489bb5b2..8712f2a27 100644 --- a/cmd/tsconnect/src/lib/ssh.ts +++ b/cmd/tsconnect/src/lib/ssh.ts @@ -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) {