Added desktop console message when getting invalid commands.

This commit is contained in:
Ylian Saint-Hilaire 2020-04-18 19:44:07 -07:00
parent 66bb5b9458
commit e5811dc37e
2 changed files with 15 additions and 7 deletions

View File

@ -212,7 +212,12 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
jumboAdd = 8;
}
if ((cmdsize != str.length) && (obj.debugmode > 0)) { console.log(cmdsize, str.length, cmdsize == str.length); }
if ((command >= 18) && (command != 65) && (command != 88)) { console.error("Invalid KVM command " + command + " of size " + cmdsize); console.log("Invalid KVM data", str.length, rstr2hex(str.substring(0, 40)) + '...'); return; }
if ((command >= 18) && (command != 65) && (command != 88)) {
console.error("Invalid KVM command " + command + " of size " + cmdsize);
console.log("Invalid KVM data", str.length, rstr2hex(str.substring(0, 40)) + '...');
if (obj.parent && obj.parent.setConsoleMessage) { obj.parent.setConsoleMessage("Invalid KVM command " + command + " of size " + cmdsize); }
return;
}
if (cmdsize > str.length) {
//console.log('KVM accumulator set to ' + str.length + ' bytes, need ' + cmdsize + ' bytes.');
obj.accumulator = str;
@ -287,10 +292,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
str = str.substring(4);
if (str[0] != '.') {
console.log(str); //alert('KVM: ' + str);
if (obj.parent != null) {
obj.parent.consoleMessage = str;
if (obj.parent.onConsoleMessageChange) { obj.parent.onConsoleMessageChange(obj.parent, str); }
}
if (obj.parent && obj.parent.setConsoleMessage) { obj.parent.setConsoleMessage(str); }
} else {
console.log('KVM: ' + str.substring(1));
}

View File

@ -72,8 +72,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
//console.log(controlMsg);
if ((typeof args != 'undefined') && args.redirtrace) { console.log('RedirRecv', controlMsg); }
if (controlMsg.type == 'console') {
obj.consoleMessage = controlMsg.msg;
if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
setConsoleMessage(controlMsg.msg);
} else if ((controlMsg.type == 'rtt') && (typeof controlMsg.time == 'number')) {
obj.latency.current = (new Date().getTime()) - controlMsg.time;
if (obj.latency.callbacks != null) { obj.latency.callback(obj.latency.current); }
@ -91,6 +90,13 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
}
}
// Set the console message
obj.setConsoleMessage = function (str) {
if (obj.consoleMessage == str) return;
obj.consoleMessage = str;
if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
}
obj.sendCtrlMsg = function (x) { if (obj.ctrlMsgAllowed == true) { if ((typeof args != 'undefined') && args.redirtrace) { console.log('RedirSend', typeof x, x); } try { obj.socket.send(x); } catch (ex) { } } }
function performWebRtcSwitch() {