aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/terminal-ssh.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xdsserver/terminal-ssh.go')
-rw-r--r--lib/xdsserver/terminal-ssh.go31
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/xdsserver/terminal-ssh.go b/lib/xdsserver/terminal-ssh.go
index 3f4a344..9a9f5fd 100644
--- a/lib/xdsserver/terminal-ssh.go
+++ b/lib/xdsserver/terminal-ssh.go
@@ -128,26 +128,19 @@ func (t *TermSSH) Open(sock *socketio.Socket, sessID string) (*xsapiv1.TerminalC
t.sshWS = eows.New(cmd, args, sock, sessID, cmdID)
t.sshWS.Log = t.Log
- t.sshWS.OutSplit = eows.SplitChar
- t.sshWS.PtsMode = true
+ t.sshWS.PtyMode = true
// Define callback for input (stdin)
t.sshWS.InputEvent = xsapiv1.TerminalInEvent
- t.sshWS.InputCB = func(e *eows.ExecOverWS, stdin string) (string, error) {
- t.Log.Debugf("STDIN <<%v>>", strings.Replace(stdin, "\n", "\\n", -1))
-
- // Handle Ctrl-D
- if len(stdin) == 1 && stdin == "\x04" {
- // Close stdin
- errMsg := fmt.Errorf("close stdin: %v", stdin)
- return "", errMsg
+ t.sshWS.InputCB = func(e *eows.ExecOverWS, stdin []byte) ([]byte, error) {
+ if t.LogLevelSilly {
+ t.Log.Debugf("STDIN <<%v>> %s", stdin, string(stdin))
}
-
return stdin, nil
}
// Define callback for output (stdout+stderr)
- t.sshWS.OutputCB = func(e *eows.ExecOverWS, stdout, stderr string) {
+ t.sshWS.OutputCB = func(e *eows.ExecOverWS, stdout, stderr []byte) {
// IO socket can be nil when disconnected
so := t.sessions.IOSocketGet(e.Sid)
if so == nil {
@@ -159,12 +152,14 @@ func (t *TermSSH) Open(sock *socketio.Socket, sessID string) (*xsapiv1.TerminalC
data := e.UserData
termID := (*data)["ID"].(string)
- t.Log.Debugf("%s emitted - WS sid[4:] %s - id:%s - termID:%s", xsapiv1.TerminalOutEvent, e.Sid[4:], e.CmdID, termID)
- if stdout != "" {
- t.Log.Debugf("STDOUT <<%v>>", strings.Replace(stdout, "\n", "\\n", -1))
- }
- if stderr != "" {
- t.Log.Debugf("STDERR <<%v>>", strings.Replace(stderr, "\n", "\\n", -1))
+ if t.LogLevelSilly {
+ t.Log.Debugf("%s emitted - WS sid[4:] %s - id:%s - termID:%s", xsapiv1.TerminalOutEvent, e.Sid[4:], e.CmdID, termID)
+ if len(stdout) > 0 {
+ t.Log.Debugf("STDOUT <<%v>>", strings.Replace(string(stdout), "\n", "\\n", -1))
+ }
+ if len(stderr) > 0 {
+ t.Log.Debugf("STDERR <<%v>>", strings.Replace(string(stderr), "\n", "\\n", -1))
+ }
}
// FIXME replace by .BroadcastTo a room