Fix escape/de-escaping for zmodem & friends
This commit is contained in:
parent
e3c197c3e1
commit
1f396e198e
|
@ -52,10 +52,13 @@ exports.getModule = class ArchaicNETModule extends MenuModule {
|
|||
let pipeRestored = false;
|
||||
let pipedStream;
|
||||
const restorePipe = function() {
|
||||
if(pipedStream && !pipeRestored && !clientTerminated) {
|
||||
if(!pipeRestored) {
|
||||
if(pipedStream && !clientTerminated) {
|
||||
self.client.term.output.unpipe(pipedStream);
|
||||
self.client.term.output.resume();
|
||||
}
|
||||
self.client.restoreDataHandler();
|
||||
}
|
||||
};
|
||||
|
||||
sshClient.on('ready', () => {
|
||||
|
@ -82,8 +85,15 @@ exports.getModule = class ArchaicNETModule extends MenuModule {
|
|||
pipedStream = stream;
|
||||
self.client.term.output.pipe(stream);
|
||||
|
||||
stream.on('data', d => {
|
||||
return self.client.term.rawWrite(d);
|
||||
// we need to filter I/O for escape/de-escaping zmodem and the like
|
||||
self.client.setTemporaryDirectDataHandler(data => {
|
||||
const tmp = data.toString('binary').replace(/\xff{2}/g, '\xff'); // de-escape
|
||||
stream.write(Buffer.from(tmp, 'binary'));
|
||||
});
|
||||
|
||||
stream.on('data', data => {
|
||||
const tmp = data.toString('binary').replace(/\xff/g, '\xff\xff'); // escape
|
||||
self.client.term.rawWrite(Buffer.from(tmp, 'binary'));
|
||||
});
|
||||
|
||||
stream.on('close', () => {
|
||||
|
|
Loading…
Reference in New Issue