mscdex / ssh2

SSH2 client and server modules written in pure JavaScript for node.js
MIT License
5.53k stars 665 forks source link

Map Server Session events to Client methods #942

Open xxorax opened 4 years ago

xxorax commented 4 years ago

My final goal is to be able to pipe a Session from a ssh2.Server Session to a ssh2.Client (once authenticated). That way I can pipe to multiple Client for example.

For most of the Server Session events, it's easy to map them to a Client method.

However there are few requests that are sent internaly in during Client.shell() or Client.exec(). It's all the todo stack that can call reqAgentFwd, reqPty, reqX11 (same in the shell() method)

In the Server, these events (for example the ptyevent) are associated to a client Session and they can theoricaly be emitted multiple times I guess. But the Client cannot send them multiple time actualy.

Also does this mean that only one "real session start" requests should be received by Session ? But it seems the server can handle more than one per Session.

Thanks !

mscdex commented 4 years ago

I'm curious what the use case is for this?

xxorax commented 4 years ago

I'm trying to make server management utility with a bastion including recording feature, it may include multi-client views (like tmux or terminator do). It's not well defined yet. For now, bastion and recording using a part of ttyrec are ok but without handling all the cases (x11, port fwd...). And for that I need to understand more when theses events should be accepted or not. It would have been easier and cleaner if I could have just send everything "as-is" to the client and catch what I need: It's what I'm trying do to.