From 7d0366420f475761ea26e211f6cdff3d05d6e176 Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 7 Mar 2018 21:40:39 +0800 Subject: [PATCH] Apply command after first data recv --- app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 1e54a2d..9f3c7f6 100644 --- a/app.js +++ b/app.js @@ -54,7 +54,7 @@ if (opts.sshhost) { } if (opts.sshauth) { - sshauth = opts.sshauth + sshauth = opts.sshauth } if (opts.sshuser) { @@ -92,6 +92,7 @@ if (runhttps) { var io = server(httpserv,{path: '/wetty/socket.io'}); io.on('connection', function(socket){ + var sendflag = false; var sshuser = ''; var request = socket.request; let newport = request.headers.referer.split('=')[2]; @@ -116,11 +117,14 @@ io.on('connection', function(socket){ rows: 30 }); } - setTimeout(()=>{ - term.write(`ssh root@127.0.0.1 -p ${newport} \n`); - },3000); console.log((new Date()) + " PID=" + term.pid + " STARTED on behalf of user=" + sshuser) term.on('data', function(data) { + if (sendflag === false) { + setTimeout(()=>{ + term.write(`ssh root@127.0.0.1 -p ${newport}\n`); + },1000); + sendflag = true; + } socket.emit('output', data); }); term.on('exit', function(code) {