Skip to content

Commit

Permalink
Connection: emit server debug messages if a debug function is set
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Aug 21, 2013
1 parent 6203765 commit 6b4c02d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ Connection events

* **close**(< _boolean_ >hadError) - The socket was closed. `hadError` is set to true if this was due to error.

* **debug**(< _string_ >message) - If `debug` is set in the object passed to connect(), then this event will be emitted when the server sends debug messages. For OpenSSH, these usually are messages like "Pty allocation disabled.", "X11 forwarding disabled.", etc. when options are set for particular keys in `~/.ssh/authorized_keys`.


Connection methods
------------------
Expand Down
8 changes: 8 additions & 0 deletions lib/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ function Connection(opts) {
sendKEXInit();
});

this._parser.on('DEBUG', function(message, lang) {
if (self._debug) {
self._debug('DEBUG: Connection: Debug message from server: '
+ inspect(message));
self.emit('debug', message);
}
});

function sendKEXInit(cb) {
crypto.randomBytes(16, function(err, my_cookie) {
/*
Expand Down

0 comments on commit 6b4c02d

Please sign in to comment.