Skip to content

Commit

Permalink
Clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Nov 22, 2016
1 parent 0aa22ed commit c77b259
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dev/telnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (e telnetNegotiationOnly) Error() string {
return "telnetNegotiationOnlyError"
}

func telnetNegotiation(buf []byte, n int, t transp) (int, error) {
func telnetNegotiation(buf []byte, n int, t transp, logger hasPrintf, debug bool) (int, error) {

timeout := 5 * time.Second // FIXME??
hitNeg := false
Expand All @@ -41,6 +41,9 @@ func telnetNegotiation(buf []byte, n int, t transp) (int, error) {
if buf[0] != cmdIAC {
break // not IAC
}
if debug {
logger.Printf("telnetNegotiation: debug: FOUND telnet IAC")
}
b1 := buf[1]
switch b1 {
case cmdDo, cmdDont:
Expand Down
10 changes: 6 additions & 4 deletions dev/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *transpTelnet) Read(b []byte) (int, error) {
if err1 != nil {
return n1, err1
}
n2, err2 := telnetNegotiation(b, n1, s)
n2, err2 := telnetNegotiation(b, n1, s, s.logger, false)
return n2, err2
}

Expand All @@ -47,6 +47,7 @@ type transpSSH struct {
session *ssh.Session
writer io.Writer
reader io.Reader
//logger hasPrintf
}

func (s *transpSSH) Read(b []byte) (int, error) {
Expand All @@ -57,7 +58,6 @@ func (s *transpSSH) Write(b []byte) (int, error) {

n, err := s.writer.Write(b)
if err != nil {
//return -1, fmt.Errorf("ssh write(%s): %v out=[%s] err=[%s]", b, err, s.out.Bytes(), s.err.Bytes())
return -1, fmt.Errorf("ssh write(%s): %v", b, err)
}

Expand Down Expand Up @@ -152,7 +152,7 @@ func openSSH(logger hasPrintf, modelName, devId, hostPort string, timeout time.D

cli := ssh.NewClient(c, chans, reqs)

s := &transpSSH{conn: conn, client: cli, devLabel: fmt.Sprintf("%s %s %s", modelName, devId, hostPort)}
s := &transpSSH{conn: conn, client: cli, devLabel: fmt.Sprintf("%s %s %s", modelName, devId, hostPort) /*, logger: logger*/}

ses, sessionErr := s.client.NewSession()
if sessionErr != nil {
Expand All @@ -161,7 +161,9 @@ func openSSH(logger hasPrintf, modelName, devId, hostPort string, timeout time.D

s.session = ses

modes := ssh.TerminalModes{}
modes := ssh.TerminalModes{
ssh.ECHO: 0, // disable echoing
}

if ptyErr := ses.RequestPty("xterm", 80, 40, modes); ptyErr != nil {
return nil, fmt.Errorf("openSSH: Pty: %s - %v", s.devLabel, ptyErr)
Expand Down

0 comments on commit c77b259

Please sign in to comment.