Move to pty-node over custom pty2.js

This commit is contained in:
Bryan Ashby 2018-03-08 21:39:42 -07:00
parent 63ff2a6057
commit f6f1de4bd8
5 changed files with 19 additions and 20 deletions

View File

@ -10,7 +10,7 @@ const resolveMimeType = require('./mime_util.js').resolveMimeType;
// base/modules // base/modules
const fs = require('graceful-fs'); const fs = require('graceful-fs');
const _ = require('lodash'); const _ = require('lodash');
const pty = require('ptyw.js'); const pty = require('node-pty');
let archiveUtil; let archiveUtil;

View File

@ -6,7 +6,7 @@ const stringFormat = require('./string_format.js');
const events = require('events'); const events = require('events');
const _ = require('lodash'); const _ = require('lodash');
const pty = require('ptyw.js'); const pty = require('node-pty');
const decode = require('iconv-lite').decode; const decode = require('iconv-lite').decode;
const createServer = require('net').createServer; const createServer = require('net').createServer;
@ -18,8 +18,7 @@ function Door(client, exeInfo) {
const self = this; const self = this;
this.client = client; this.client = client;
this.exeInfo = exeInfo; this.exeInfo = exeInfo;
this.exeInfo.encoding = this.exeInfo.encoding || 'cp437'; this.exeInfo.encoding = (this.exeInfo.encoding || 'cp437').toLowerCase();
this.exeInfo.encoding = this.exeInfo.encoding.toLowerCase();
let restored = false; let restored = false;
// //
@ -36,11 +35,7 @@ function Door(client, exeInfo) {
// //
this.doorDataHandler = function(data) { this.doorDataHandler = function(data) {
if(self.client.term.outputEncoding === self.exeInfo.encoding) {
self.client.term.rawWrite(data);
} else {
self.client.term.write(decode(data, self.exeInfo.encoding)); self.client.term.write(decode(data, self.exeInfo.encoding));
}
}; };
this.restoreIo = function(piped) { this.restoreIo = function(piped) {
@ -117,6 +112,7 @@ Door.prototype.run = function() {
rows : self.client.term.termHeight, rows : self.client.term.termHeight,
// :TODO: cwd // :TODO: cwd
env : self.exeInfo.env, env : self.exeInfo.env,
encoding : null, // we want to handle all encoding ourself
}); });
if('stdio' === self.exeInfo.io) { if('stdio' === self.exeInfo.io) {

View File

@ -9,7 +9,7 @@ const Log = require('./logger.js').log;
const _ = require('lodash'); const _ = require('lodash');
const later = require('later'); const later = require('later');
const path = require('path'); const path = require('path');
const pty = require('ptyw.js'); const pty = require('node-pty');
const sane = require('sane'); const sane = require('sane');
const moment = require('moment'); const moment = require('moment');
const paths = require('path'); const paths = require('path');

View File

@ -14,7 +14,7 @@ const Log = require('./logger.js').log;
// deps // deps
const async = require('async'); const async = require('async');
const _ = require('lodash'); const _ = require('lodash');
const pty = require('ptyw.js'); const pty = require('node-pty');
const temptmp = require('temptmp').createTrackedSession('transfer_file'); const temptmp = require('temptmp').createTrackedSession('transfer_file');
const paths = require('path'); const paths = require('path');
const fs = require('graceful-fs'); const fs = require('graceful-fs');
@ -361,11 +361,14 @@ exports.getModule = class TransferFileModule extends MenuModule {
'Executing external protocol' 'Executing external protocol'
); );
const externalProc = pty.spawn(cmd, args, { const spawnOpts = {
cols : this.client.term.termWidth, cols : this.client.term.termWidth,
rows : this.client.term.termHeight, rows : this.client.term.termHeight,
cwd : this.recvDirectory, cwd : this.recvDirectory,
}); encoding : null, // don't bork our data!
};
const externalProc = pty.spawn(cmd, args, spawnOpts);
this.client.setTemporaryDirectDataHandler(data => { this.client.setTemporaryDirectDataHandler(data => {
// needed for things like sz/rz // needed for things like sz/rz

View File

@ -40,7 +40,7 @@
"minimist": "1.2.x", "minimist": "1.2.x",
"moment": "^2.20.1", "moment": "^2.20.1",
"nodemailer": "^4.4.1", "nodemailer": "^4.4.1",
"ptyw.js": "NuSkooler/ptyw.js", "node-pty": "^0.7.4",
"rlogin": "^1.0.0", "rlogin": "^1.0.0",
"sane": "^2.2.0", "sane": "^2.2.0",
"sanitize-filename": "^1.6.1", "sanitize-filename": "^1.6.1",