Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1479)

Delta Between Two Patch Sets: ssh/server_terminal.go

Issue 14225043: code review 14225043: go.crypto/ssh: reimplement SSH connection protocol modu... (Closed)
Left Patch Set: diff -r 5ff5636e18c9 https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Right Patch Set: diff -r cd1eea1eb828 https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ssh/server.go ('k') | ssh/session.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package ssh 5 package ssh
6 6
7 // A Terminal is capable of parsing and generating virtual terminal 7 // A Terminal is capable of parsing and generating virtual terminal
8 // data from an SSH client. 8 // data from an SSH client.
9 type Terminal interface { 9 type Terminal interface {
10 ReadLine() (line string, err error) 10 ReadLine() (line string, err error)
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 return 42 return
43 } 43 }
44 44
45 func (ss *ServerTerminal) Write(buf []byte) (n int, err error) { 45 func (ss *ServerTerminal) Write(buf []byte) (n int, err error) {
46 return ss.Term.Write(buf) 46 return ss.Term.Write(buf)
47 } 47 }
48 48
49 // ReadLine returns a line of input from the terminal. 49 // ReadLine returns a line of input from the terminal.
50 func (ss *ServerTerminal) ReadLine() (line string, err error) { 50 func (ss *ServerTerminal) ReadLine() (line string, err error) {
51 » return ss.Term.ReadLine() 51 » for {
52 } 52 » » if line, err = ss.Term.ReadLine(); err == nil {
53 » » » return
54 » » }
55 » » req, ok := err.(ChannelRequest)
56 » » if !ok {
57 » » » return
58 » » }
53 59
54 func (ss *ServerTerminal) HandleRequests() { 60 » » ok = false
55 » for req := range ss.Channel.IncomingRequests() {
56 » » ok := false
57 switch req.Request { 61 switch req.Request {
58 case "pty-req": 62 case "pty-req":
59 var width, height int 63 var width, height int
60 width, height, ok = parsePtyRequest(req.Payload) 64 width, height, ok = parsePtyRequest(req.Payload)
61 ss.Term.SetSize(width, height) 65 ss.Term.SetSize(width, height)
62 case "shell": 66 case "shell":
63 ok = true 67 ok = true
64 if len(req.Payload) > 0 { 68 if len(req.Payload) > 0 {
65 // We don't accept any commands, only the defaul t shell. 69 // We don't accept any commands, only the defaul t shell.
66 ok = false 70 ok = false
67 } 71 }
68 case "env": 72 case "env":
69 ok = true 73 ok = true
70 } 74 }
71 if req.WantReply { 75 if req.WantReply {
72 ss.Channel.AckRequest(ok) 76 ss.Channel.AckRequest(ok)
73 } 77 }
74 } 78 }
79 panic("unreachable")
75 } 80 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b