Fix escape/de-escaping for zmodem & friends
This commit is contained in:
parent
e3c197c3e1
commit
1f396e198e
|
@ -52,9 +52,12 @@ exports.getModule = class ArchaicNETModule extends MenuModule {
|
||||||
let pipeRestored = false;
|
let pipeRestored = false;
|
||||||
let pipedStream;
|
let pipedStream;
|
||||||
const restorePipe = function() {
|
const restorePipe = function() {
|
||||||
if(pipedStream && !pipeRestored && !clientTerminated) {
|
if(!pipeRestored) {
|
||||||
self.client.term.output.unpipe(pipedStream);
|
if(pipedStream && !clientTerminated) {
|
||||||
self.client.term.output.resume();
|
self.client.term.output.unpipe(pipedStream);
|
||||||
|
self.client.term.output.resume();
|
||||||
|
}
|
||||||
|
self.client.restoreDataHandler();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,8 +85,15 @@ exports.getModule = class ArchaicNETModule extends MenuModule {
|
||||||
pipedStream = stream;
|
pipedStream = stream;
|
||||||
self.client.term.output.pipe(stream);
|
self.client.term.output.pipe(stream);
|
||||||
|
|
||||||
stream.on('data', d => {
|
// we need to filter I/O for escape/de-escaping zmodem and the like
|
||||||
return self.client.term.rawWrite(d);
|
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', () => {
|
stream.on('close', () => {
|
||||||
|
|
Loading…
Reference in New Issue