Fixed meshctrl.js shell when ping/pong are active.
This commit is contained in:
parent
3a92c077b9
commit
3b637ad389
|
@ -1610,7 +1610,7 @@ function onTunnelClosed() {
|
||||||
function onTunnelSendOk() { /*sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid);*/ }
|
function onTunnelSendOk() { /*sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid);*/ }
|
||||||
function onTunnelData(data) {
|
function onTunnelData(data) {
|
||||||
//console.log("OnTunnelData");
|
//console.log("OnTunnelData");
|
||||||
sendConsoleText('OnTunnelData, ' + data.length + ', ' + typeof data + ', ' + data);
|
//sendConsoleText('OnTunnelData, ' + data.length + ', ' + typeof data + ', ' + data);
|
||||||
|
|
||||||
// If this is upload data, save it to file
|
// If this is upload data, save it to file
|
||||||
if ((this.httprequest.uploadFile) && (typeof data == 'object') && (data[0] != 123)) {
|
if ((this.httprequest.uploadFile) && (typeof data == 'object') && (data[0] != 123)) {
|
||||||
|
@ -2547,7 +2547,7 @@ function onTunnelControlData(data, ws) {
|
||||||
if (ws == null) { ws = this; }
|
if (ws == null) { ws = this; }
|
||||||
if (typeof data == 'string') { try { obj = JSON.parse(data); } catch (e) { sendConsoleText('Invalid control JSON: ' + data); return; } }
|
if (typeof data == 'string') { try { obj = JSON.parse(data); } catch (e) { sendConsoleText('Invalid control JSON: ' + data); return; } }
|
||||||
else if (typeof data == 'object') { obj = data; } else { return; }
|
else if (typeof data == 'object') { obj = data; } else { return; }
|
||||||
sendConsoleText('onTunnelControlData(' + ws.httprequest.protocol + '): ' + JSON.stringify(data));
|
//sendConsoleText('onTunnelControlData(' + ws.httprequest.protocol + '): ' + JSON.stringify(data));
|
||||||
//console.log('onTunnelControlData: ' + JSON.stringify(data));
|
//console.log('onTunnelControlData: ' + JSON.stringify(data));
|
||||||
|
|
||||||
switch (obj.type) {
|
switch (obj.type) {
|
||||||
|
|
|
@ -1968,6 +1968,12 @@ function connectTunnel(url) {
|
||||||
settings.tunnelws.on('message', function (rawdata) {
|
settings.tunnelws.on('message', function (rawdata) {
|
||||||
var data = rawdata.toString();
|
var data = rawdata.toString();
|
||||||
if (settings.tunnelwsstate == 1) {
|
if (settings.tunnelwsstate == 1) {
|
||||||
|
// If the incoming text looks exactly like a control command, ignore it.
|
||||||
|
if ((typeof data == 'string') && (data.startsWith('{"ctrlChannel":"102938","type":"'))) {
|
||||||
|
var ctrlCmd = null;
|
||||||
|
try { ctrlCmd = JSON.parse(data); } catch (ex) { }
|
||||||
|
if ((ctrlCmd != null) && (ctrlCmd.ctrlChannel == '102938') && (ctrlCmd.type != null)) return; // This is a control command, like ping/pong. Ignore it.
|
||||||
|
}
|
||||||
process.stdout.write(data);
|
process.stdout.write(data);
|
||||||
} else if (settings.tunnelwsstate == 0) {
|
} else if (settings.tunnelwsstate == 0) {
|
||||||
if (data == 'c') { console.log('Connected.'); } else if (data == 'cr') { console.log('Connected, session is being recorded.'); } else return;
|
if (data == 'c') { console.log('Connected.'); } else if (data == 'cr') { console.log('Connected, session is being recorded.'); } else return;
|
||||||
|
|
Loading…
Reference in New Issue