diff --git a/package.json b/package.json index e3613df5..366f490b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.7-k", + "version": "0.2.7-m", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/scripts/agent-redir-rtc-0.1.0.js b/public/scripts/agent-redir-rtc-0.1.0.js index 6cf1189a..d274869b 100644 --- a/public/scripts/agent-redir-rtc-0.1.0.js +++ b/public/scripts/agent-redir-rtc-0.1.0.js @@ -28,6 +28,45 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) { obj.rtcKeepAlive = setInterval(obj.xxSendRtcKeepAlive, 30000); } + // Setup the file reader + var fileReader = new FileReader(); + var fileReaderInuse = false, fileReaderAcc = []; + if (fileReader.readAsBinaryString) { + // Chrome & Firefox (Draft) + fileReader.onload = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } } + } else if (fileReader.readAsArrayBuffer) { + // Chrome & Firefox (Spec) + fileReader.onloadend = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } } + } + + obj.xxOnMessage = function (e) { + //if (obj.debugmode == 1) { console.log('Recv', e.data); } + //if (urlvars && urlvars['webrtctrace']) { console.log('WebRTC-Recv(' + obj.State + '): ', typeof e.data, e.data); } + if (typeof e.data == 'string') { if (obj.onControlMsg != null) { obj.onControlMsg(e.data); } return; } // If this is a control message, handle it here. + if (typeof e.data == 'object') { + if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; } + if (fileReader.readAsBinaryString) { + // Chrome & Firefox (Draft) + fileReaderInuse = true; + fileReader.readAsBinaryString(new Blob([e.data])); + } else if (f.readAsArrayBuffer) { + // Chrome & Firefox (Spec) + fileReaderInuse = true; + fileReader.readAsArrayBuffer(e.data); + } else { + // IE10, readAsBinaryString does not exist, use an alternative. + var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength; + for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); } + obj.xxOnSocketData(binary); + } + } else { + // If we get a string object, it maybe the WebRTC confirm. Ignore it. + //obj.debug("Agent Redir Relay - OnData - " + typeof e.data + " - " + e.data.length); + obj.xxOnSocketData(e.data); + } + }; + + /* obj.xxOnMessage = function (e) { //if (obj.debugmode == 1) { console.log('Recv', e.data); } //if (urlvars && urlvars['webrtctrace']) { console.log('WebRTC-Recv(' + obj.State + '): ', typeof e.data, e.data); } @@ -54,7 +93,8 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) { obj.xxOnSocketData(e.data); } }; - + */ + obj.xxOnSocketData = function (data) { if (!data) return; if (typeof data === 'object') { diff --git a/public/scripts/amt-ider-ws-0.0.1.js b/public/scripts/amt-ider-ws-0.0.1.js index c993d6f9..634e9d1f 100644 --- a/public/scripts/amt-ider-ws-0.0.1.js +++ b/public/scripts/amt-ider-ws-0.0.1.js @@ -58,22 +58,29 @@ var CreateAmtRemoteIder = function (serverurl) { _Send('C'); } + // Setup the file reader + var fileReader = new FileReader(); + var fileReaderInuse = false, fileReaderAcc = []; + if (fileReader.readAsBinaryString) { + // Chrome & Firefox (Draft) + fileReader.onload = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } } + } else if (fileReader.readAsArrayBuffer) { + // Chrome & Firefox (Spec) + fileReader.onloadend = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } } + } + function _OnMessage(e) { if (typeof e.data == 'object') { - var f = new FileReader(); - if (f.readAsBinaryString) { + if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; } + if (fileReader.readAsBinaryString) { // Chrome & Firefox (Draft) - f.onload = function (e) { _OnSocketData(e.target.result); } - f.readAsBinaryString(new Blob([e.data])); - } else if (f.readAsArrayBuffer) { + fileReader.readAsBinaryString(new Blob([e.data])); + } else if (fileReader.readAsArrayBuffer) { // Chrome & Firefox (Spec) - f.onloadend = function (e) { _OnSocketData(e.target.result); } - f.readAsArrayBuffer(e.data); + fileReader.readAsArrayBuffer(e.data); } else { // IE10, readAsBinaryString does not exist, use an alternative. - var binary = ""; - var bytes = new Uint8Array(e.data); - var length = bytes.byteLength; + var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength; for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); } _OnSocketData(binary); } diff --git a/public/scripts/amt-redir-ws-0.1.0.js b/public/scripts/amt-redir-ws-0.1.0.js index a243d332..5b18bfce 100644 --- a/public/scripts/amt-redir-ws-0.1.0.js +++ b/public/scripts/amt-redir-ws-0.1.0.js @@ -59,24 +59,33 @@ var CreateAmtRedirect = function (module, authCookie) { if (obj.protocol == 3) obj.xxSend(obj.RedirectStartIder); } + // Setup the file reader + var fileReader = new FileReader(); + var fileReaderInuse = false, fileReaderAcc = []; + if (fileReader.readAsBinaryString) { + // Chrome & Firefox (Draft) + fileReader.onload = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } } + } else if (fileReader.readAsArrayBuffer) { + // Chrome & Firefox (Spec) + fileReader.onloadend = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } } + } + obj.xxOnMessage = function (e) { //if (obj.debugmode == 1) { console.log('Recv', e.data); } obj.inDataCount++; if (typeof e.data == 'object') { - var f = new FileReader(); - if (f.readAsBinaryString) { + if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; } + if (fileReader.readAsBinaryString) { // Chrome & Firefox (Draft) - f.onload = function (e) { obj.xxOnSocketData(e.target.result); } - f.readAsBinaryString(new Blob([e.data])); + fileReaderInuse = true; + fileReader.readAsBinaryString(new Blob([e.data])); } else if (f.readAsArrayBuffer) { // Chrome & Firefox (Spec) - f.onloadend = function (e) { obj.xxOnSocketData(e.target.result); } - f.readAsArrayBuffer(e.data); + fileReaderInuse = true; + fileReader.readAsArrayBuffer(e.data); } else { // IE10, readAsBinaryString does not exist, use an alternative. - var binary = ""; - var bytes = new Uint8Array(e.data); - var length = bytes.byteLength; + var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength; for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); } obj.xxOnSocketData(binary); } @@ -88,7 +97,6 @@ var CreateAmtRedirect = function (module, authCookie) { }; obj.xxOnSocketData = function (data) { - //if (obj.debugmode == 1) { console.log('Recv', data.length, rstr2hex(data)); } if (!data || obj.connectstate == -1) return; if (typeof data === 'object') { @@ -250,7 +258,7 @@ var CreateAmtRedirect = function (module, authCookie) { obj.xxSend = function (x) { //obj.Debug("Redir Send(" + x.length + "): " + rstr2hex(x)); if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) { - //if (obj.debugmode == 1) { console.log('Send', x.length, rstr2hex(x)); } + if (obj.debugmode == 1) { console.log('Send', x); } var b = new Uint8Array(x.length); for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); } obj.socket.send(b.buffer); diff --git a/public/scripts/amt-wsman-ws-0.2.0.js b/public/scripts/amt-wsman-ws-0.2.0.js index c0e65002..4f00dc9e 100644 --- a/public/scripts/amt-wsman-ws-0.2.0.js +++ b/public/scripts/amt-wsman-ws-0.2.0.js @@ -130,27 +130,33 @@ var CreateWsmanComm = function (host, port, user, pass, tls) { for (i in obj.pendingAjaxCall) { obj.sendRequest(obj.pendingAjaxCall[i][0], obj.pendingAjaxCall[i][3], obj.pendingAjaxCall[i][4]); } } + // Setup the file reader + var fileReader = new FileReader(); + var fileReaderInuse = false, fileReaderAcc = []; + if (fileReader.readAsBinaryString) { + // Chrome & Firefox (Draft) + fileReader.onload = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } } + } else if (fileReader.readAsArrayBuffer) { + // Chrome & Firefox (Spec) + fileReader.onloadend = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } } + } + function _OnMessage(e) { if (typeof e.data == 'object') { - var f = new FileReader(); - if (f.readAsBinaryString) { + if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; } + if (fileReader.readAsBinaryString) { // Chrome & Firefox (Draft) - f.onload = function (e) { _OnSocketData(e.target.result); } - f.readAsBinaryString(new Blob([e.data])); - } else if (f.readAsArrayBuffer) { + fileReader.readAsBinaryString(new Blob([e.data])); + } else if (fileReader.readAsArrayBuffer) { // Chrome & Firefox (Spec) - f.onloadend = function (e) { _OnSocketData(e.target.result); } - f.readAsArrayBuffer(e.data); + fileReader.readAsArrayBuffer(e.data); } else { // IE10, readAsBinaryString does not exist, use an alternative. - var binary = ""; - var bytes = new Uint8Array(e.data); - var length = bytes.byteLength; + var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength; for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); } _OnSocketData(binary); } - } else if (typeof e.data == 'string') { - // We got a string object + } else { _OnSocketData(e.data); } }; diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 5eba2814..14b7f845 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ -
{{{logoutControl}}}
My Devices | My Account | My Events | My Files |
{{{logoutControl}}}
My Devices | My Account | My Events | My Files |