Added desktop console message when getting invalid commands.
Ylian Saint-Hilaire committed
Apr 18, 2020 at 19:44 UTC
e5811dc37e184e7554542de3208cc0edd7d8cb98
2 files changed
+15
-7
public/scripts/agent-desktop-0.0.2.js
+7
-5
@@ -212,7 +212,12 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
212
jumboAdd = 8;
213
}
214
if ((cmdsize != str.length) && (obj.debugmode > 0)) { console.log(cmdsize, str.length, cmdsize == str.length); }
215
- 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; }
215
+ if ((command >= 18) && (command != 65) && (command != 88)) {
216
+ console.error("Invalid KVM command " + command + " of size " + cmdsize);
217
+ console.log("Invalid KVM data", str.length, rstr2hex(str.substring(0, 40)) + '...');
218
+ if (obj.parent && obj.parent.setConsoleMessage) { obj.parent.setConsoleMessage("Invalid KVM command " + command + " of size " + cmdsize); }
219
+ return;
220
+ }
221
if (cmdsize > str.length) {
222
//console.log('KVM accumulator set to ' + str.length + ' bytes, need ' + cmdsize + ' bytes.');
223
obj.accumulator = str;
@@ -287,10 +292,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
292
str = str.substring(4);
293
if (str[0] != '.') {
294
console.log(str); //alert('KVM: ' + str);
290
- if (obj.parent != null) {
291
- obj.parent.consoleMessage = str;
292
- if (obj.parent.onConsoleMessageChange) { obj.parent.onConsoleMessageChange(obj.parent, str); }
293
- }
295
+ if (obj.parent && obj.parent.setConsoleMessage) { obj.parent.setConsoleMessage(str); }
296
} else {
297
console.log('KVM: ' + str.substring(1));
298
}
public/scripts/agent-redir-ws-0.1.1.js
+8
-2
@@ -72,8 +72,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
72
//console.log(controlMsg);
73
if ((typeof args != 'undefined') && args.redirtrace) { console.log('RedirRecv', controlMsg); }
74
if (controlMsg.type == 'console') {
75
- obj.consoleMessage = controlMsg.msg;
76
- if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
75
+ setConsoleMessage(controlMsg.msg);
76
} else if ((controlMsg.type == 'rtt') && (typeof controlMsg.time == 'number')) {
77
obj.latency.current = (new Date().getTime()) - controlMsg.time;
78
if (obj.latency.callbacks != null) { obj.latency.callback(obj.latency.current); }
@@ -91,6 +90,13 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
90
}
91
}
92
93
+ // Set the console message
94
+ obj.setConsoleMessage = function (str) {
95
+ if (obj.consoleMessage == str) return;
96
+ obj.consoleMessage = str;
97
+ if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
98
+ }
99
+
100
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) { } } }
101
102
function performWebRtcSwitch() {