Skip to content

Commit

Permalink
can now open up a shell channel properly
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 20, 2011
1 parent be84adc commit 2cd9bfc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/chan.cc
Expand Up @@ -61,17 +61,16 @@ int Chan::ReadChannelAfter(eio_req *req) {

while (!chan->buffers.empty()) {
std::pair<int, char *> p = chan->buffers.front();
int i = p.first;
if (i == 0) {
chan->buffers.pop_front();
if (p.first == 0) {
chan->Emit(String::NewSymbol("end"), 0, NULL);
}
else {
char *buf = p.second;
Handle<Object> bufObj;
Buffer::New(p.second, i)->Wrap(bufObj);;
Buffer *b = Buffer::New(p.second, p.first);
b->Ref();

Handle<Value> argv[1];
argv[0] = bufObj;
argv[0] = b->handle_;
chan->Emit(String::NewSymbol("data"), 1, argv);
delete p.second;
}
Expand Down
1 change: 1 addition & 0 deletions src/chan.h
Expand Up @@ -2,6 +2,7 @@
#define NODE_SSH_CHAN_H

#define protected public
#define private public

#include <node.h>
#include <node_object_wrap.h>
Expand Down
3 changes: 0 additions & 3 deletions test.js
Expand Up @@ -30,11 +30,9 @@ server.on('session', function (s) {
}
else if (m.type === sshd.constants.SSH_REQUEST_CHANNEL_OPEN
&& m.subtype === sshd.constants.SSH_CHANNEL_SESSION) {
console.log('channel!');
var ch = m.openChannel();
console.dir({ ch : ch });
ch.on('data', function (buf) {
console.log('!!!!!!!!!!!!!!!!!!!!!!! got data!');
console.log(buf);
});
ch.on('end', function () {
Expand All @@ -43,7 +41,6 @@ server.on('session', function (s) {
}
else if (m.type === sshd.constants.SSH_REQUEST_CHANNEL
&& m.subtype === sshd.constants.SSH_CHANNEL_REQUEST_SHELL) {
console.log("reply success!");
m.channelReplySuccess();
}
else {
Expand Down

0 comments on commit 2cd9bfc

Please sign in to comment.