1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Improved file transfers, added file downloads over WebRTC.

This commit is contained in:
Ylian Saint-Hilaire 2018-02-11 17:13:26 -08:00
parent 2a835d25cd
commit 0c3c0973bc
28 changed files with 579 additions and 230 deletions

View file

@ -539,8 +539,8 @@ th {
</div>
<div id="dialog12" style="margin:auto;margin:3px">
<br>
<div style='height:26px'><input id="idx_d12name" style="float:right;width:200px" onkeyup="updateWifiDialog()"><div>Profile Name</div></div>
<div style='height:26px'><input id="idx_d12ssid" style="float:right;width:200px" onkeyup="updateWifiDialog()"><div>SSID</div></div>
<div style='height:26px'><input id="idx_d12name" style="float:right;width:200px" maxlength="32" onkeyup="updateWifiDialog()" title="Maximum 32 characters"><div title="Maximum 32 characters">Profile Name</div></div>
<div style='height:26px'><input id="idx_d12ssid" style="float:right;width:200px" maxlength="32" onkeyup="updateWifiDialog()" title="Maximum 32 characters"><div title="Maximum 32 characters">SSID</div></div>
<div style='height:26px'>
<select id="idx_d12pri" style="float:right;width:200px" onclick="updateWifiDialog()"></select>
<div>Priority</div>
@ -565,8 +565,8 @@ th {
</select>
<div>Encryption</div>
</div>
<div style='height:26px'><input id="idx_d12password1" type="password" style="float:right;width:200px" onkeyup="updateWifiDialog()"><div>Password*</div></div>
<div style='height:26px'><input id="idx_d12password2" type="password" style="float:right;width:200px" onkeyup="updateWifiDialog()"><div>Confirm Password</div></div>
<div style='height:26px'><input id="idx_d12password1" type="password" style="float:right;width:200px" maxlength="63" onkeyup="updateWifiDialog()" title="Length between 8 and 63 characters"><div title="Length between 8 and 63 characters">Password*</div></div>
<div style='height:26px'><input id="idx_d12password2" type="password" style="float:right;width:200px" maxlength="63" onkeyup="updateWifiDialog()" title="Length between 8 and 63 characters"><div title="Length between 8 and 63 characters">Confirm Password</div></div>
</div>
<div id="dialog19" style="margin:auto;margin:3px">
This will save the entire state of Intel&reg; AMT for this machine into file. Passwords will not be saved, but some sensitive data may be included.<br><br>
@ -1504,7 +1504,7 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
// Perform a WSMAN PULL operation
obj.ExecPull = function (resuri, enumctx, callback, tag, pri) {
obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>", callback, tag, pri);
obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext></Pull></Body></Envelope>", callback, tag, pri); // </EnumerationContext>--<MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters>--</Pull>
}
// Private method
@ -1644,9 +1644,8 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
function _turnToXml(text) {
if (window.DOMParser) {
return new DOMParser().parseFromString(text, "text/xml");
}
else // Internet Explorer
{
} else {
// Internet Explorer
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(text);
@ -1823,9 +1822,9 @@ function AmtStackCreateService(wsmanStack) {
if (response == null || response.Header["Method"] != "PullResponse") { callback(obj, name, null, 604, tag); _EnumDoNext(1); return; }
for (var i in response.Body["Items"]) {
if (response.Body["Items"][i] instanceof Array) {
for (var j in response.Body["Items"][i]) { items.push(response.Body["Items"][i][j]); }
for (var j in response.Body["Items"][i]) { if (typeof response.Body["Items"][i][j] != 'function') { items.push(response.Body["Items"][i][j]); } }
} else {
items.push(response.Body["Items"][i]);
if (typeof response.Body["Items"][i] != 'function') { items.push(response.Body["Items"][i]); }
}
}
if (response.Body["EnumerationContext"]) {
@ -2078,6 +2077,8 @@ function AmtStackCreateService(wsmanStack) {
obj.IPS_HostBasedSetupService_UpgradeClientToAdmin = function (McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "UpgradeClientToAdmin", { "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
obj.IPS_HostBasedSetupService_DisableClientControlMode = function (_method_dummy, callback_func) { obj.Exec("IPS_HostBasedSetupService", "DisableClientControlMode", { "_method_dummy": _method_dummy }, callback_func); }
obj.IPS_KVMRedirectionSettingData_TerminateSession = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "TerminateSession", {}, callback_func); }
obj.IPS_KVMRedirectionSettingData_DataChannelRead = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelRead", {}, callback_func); }
obj.IPS_KVMRedirectionSettingData_DataChannelWrite = function (Data, callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelWrite", { "DataMessage": Data }, callback_func); }
obj.IPS_OptInService_StartOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "StartOptIn", {}, callback_func); }
obj.IPS_OptInService_CancelOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "CancelOptIn", {}, callback_func); }
obj.IPS_OptInService_SendOptInCode = function (OptInCode, callback_func) { obj.Exec("IPS_OptInService", "SendOptInCode", { "OptInCode": OptInCode }, callback_func); }
@ -33061,7 +33062,7 @@ if (typeof module !== "undefined" && module.exports) {
});
}
var version = '0.5.8';
var version = '0.6.0';
var urlvars = null;
var amtstack;
var wsstack = null;
@ -33398,7 +33399,7 @@ if (typeof module !== "undefined" && module.exports) {
}
}
}
if (amtlogicalelements.length == 0) { disconnect(); return; } // Could not get Intel AMT version, disconnect();
if (amtlogicalelements.length == 0) { console.error('ERROR: Could not get Intel AMT version.'); disconnect(); return; } // Could not get Intel AMT version, disconnect();
var v = getInstance(amtlogicalelements, "AMT")["VersionString"];
amtversion = parseInt(v.split('.')[0]);
amtversionmin = parseInt(v.split('.')[1]);
@ -34602,9 +34603,7 @@ if (typeof module !== "undefined" && module.exports) {
xx += getWatchdogTransitionStr(t['OldState']) + " &rarr; " + getWatchdogTransitionStr(t['NewState']);
if (t.actions) {
var action = t.actions[0];
if (action['EventOnTransition'] == true) {
xx += " : Event to log";
}
if (action['EventOnTransition'] == true) { xx += " : Event to log"; }
}
}
if (xx != '') { x += "<div style=padding:12px>" + xx + "</div>"; }
@ -35298,8 +35297,7 @@ if (typeof module !== "undefined" && module.exports) {
'__parameterType': 'reference',
'__resourceUri': amtstack.CompleteName('CIM_WiFiEndpoint'),
'Name': 'WiFi Endpoint 0'
},
{
}, {
'__parameterType': 'instance',
'__namespace': amtstack.CompleteName('CIM_WiFiEndpointSettings'),
'ElementName': idx_d12name.value,
@ -35328,7 +35326,7 @@ if (typeof module !== "undefined" && module.exports) {
// Check if there is already a profile with this name
for (var j in xxWireless['CIM_WiFiEndpointSettings'].responses) { if (xxWireless['CIM_WiFiEndpointSettings'].responses[j]['ElementName'] == idx_d12name.value) { r = false; } }
QE('idx_dlgOkButton', r == true && idx_d12name.value.length > 0 && idx_d12ssid.value.length > 0 && idx_d12password1.value.length > 0 && idx_d12password1.value == idx_d12password2.value);
QE('idx_dlgOkButton', r == true && (idx_d12name.value.length > 0) && (idx_d12ssid.value.length > 0) && (idx_d12password1.value.length > 7) && (idx_d12password1.value == idx_d12password2.value));
}
@ -35598,7 +35596,7 @@ if (typeof module !== "undefined" && module.exports) {
QE('idx_dlgOkButton', ok);
}
var xxUserPermissions = [ 'Local only' , 'Network only', 'All (Local & Network)'];
var xxUserPermissions = ['Local only' , 'Network only', 'All (Local & Network)'];
function showUserDetails(h) {
if (xxdialogMode) return;
var a = xxAccountRealmInfo[h], x = '<div style=text-align:left>';
@ -36275,7 +36273,7 @@ if (typeof module !== "undefined" && module.exports) {
delete x["DefaultGateway"];
delete x["PrimaryDNS"];
delete x["SecondaryDNS"];
if (!y) {
if (d21o1.checked == false) {
x["IPAddress"] = idx_d21address.value;
x["SubnetMask"] = idx_d21subnet.value;
x["DefaultGateway"] = idx_d21gateway.value;

View file

@ -83,9 +83,9 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
}
}
obj.Send = function (x) {
obj.send = function (x) {
//console.log("KSend(" + x.length + "): " + rstr2hex(x));
obj.parent.Send(x);
obj.parent.send(x);
}
// KVM Control.
@ -138,24 +138,24 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.SendUnPause = function () {
//obj.Debug("SendUnPause");
//obj.xxStateChange(3);
obj.Send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x00));
obj.send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x00));
}
obj.SendPause = function () {
//obj.Debug("SendPause");
//obj.xxStateChange(2);
obj.Send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x01));
obj.send(String.fromCharCode(0x00, 0x08, 0x00, 0x05, 0x01));
}
obj.SendCompressionLevel = function (type, level, scaling, frametimer) {
if (level) { obj.CompressionLevel = level; }
if (scaling) { obj.ScalingLevel = scaling; }
if (frametimer) { obj.FrameRateTimer = frametimer; }
obj.Send(String.fromCharCode(0x00, 0x05, 0x00, 0x0A, type, obj.CompressionLevel) + obj.shortToStr(obj.ScalingLevel) + obj.shortToStr(obj.FrameRateTimer));
obj.send(String.fromCharCode(0x00, 0x05, 0x00, 0x0A, type, obj.CompressionLevel) + obj.shortToStr(obj.ScalingLevel) + obj.shortToStr(obj.FrameRateTimer));
}
obj.SendRefresh = function () {
obj.Send(String.fromCharCode(0x00, 0x06, 0x00, 0x04));
obj.send(String.fromCharCode(0x00, 0x06, 0x00, 0x04));
}
obj.ProcessScreenMsg = function (width, height) {
@ -214,7 +214,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.SendKeyMsgKC(obj.KeyAction.UP, 91); // Left-Windows
obj.SendKeyMsgKC(obj.KeyAction.UP, 92); // Right-Windows
obj.SendKeyMsgKC(obj.KeyAction.UP, 16); // Shift
obj.Send(String.fromCharCode(0x00, 0x0E, 0x00, 0x04));
obj.send(String.fromCharCode(0x00, 0x0E, 0x00, 0x04));
break;
case 11: // GetDisplays
var myOptions = [], dcount = ((str.charCodeAt(4) & 0xFF) << 8) + (str.charCodeAt(5) & 0xFF);
@ -268,21 +268,21 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
}
obj.SendMessage = function (msg) {
if (obj.State == 3) obj.Send(String.fromCharCode(0x00, 0x11) + obj.shortToStr(4 + msg.length) + msg); // 0x11 = 17 MNG_KVM_MESSAGE
if (obj.State == 3) obj.send(String.fromCharCode(0x00, 0x11) + obj.shortToStr(4 + msg.length) + msg); // 0x11 = 17 MNG_KVM_MESSAGE
}
obj.SendKeyMsgKC = function (action, kc) {
if (obj.State == 3) obj.Send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, (action - 1), kc));
if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, (action - 1), kc));
}
obj.sendcad = function() { obj.SendCtrlAltDelMsg(); }
obj.SendCtrlAltDelMsg = function () {
if (obj.State == 3) { obj.Send(String.fromCharCode(0x00, obj.InputType.CTRLALTDEL, 0x00, 0x04)); }
if (obj.State == 3) { obj.send(String.fromCharCode(0x00, obj.InputType.CTRLALTDEL, 0x00, 0x04)); }
}
obj.SendEscKey = function () {
if (obj.State == 3) obj.Send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, 0x00, 0x1B, 0x00, obj.InputType.KEY, 0x00, 0x06, 0x01, 0x1B));
if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.KEY, 0x00, 0x06, 0x00, 0x1B, 0x00, obj.InputType.KEY, 0x00, 0x06, 0x01, 0x1B));
}
obj.SendStartMsg = function () {
@ -298,7 +298,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
}
obj.SendTouchMsg1 = function (id, flags, x, y) {
if (obj.State == 3) obj.Send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(14) + String.fromCharCode(0x01, id) + obj.intToStr(flags) + obj.shortToStr(x) + obj.shortToStr(y));
if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(14) + String.fromCharCode(0x01, id) + obj.intToStr(flags) + obj.shortToStr(x) + obj.shortToStr(y));
}
obj.SendTouchMsg2 = function (id, flags) {
@ -314,7 +314,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
msg += String.fromCharCode(k) + obj.intToStr(flags2) + obj.shortToStr(obj.TouchArray[k].x) + obj.shortToStr(obj.TouchArray[k].y);
if (obj.TouchArray[k].f == 2) delete obj.TouchArray[k];
}
if (obj.State == 3) obj.Send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(5 + msg.length) + String.fromCharCode(0x02) + msg);
if (obj.State == 3) obj.send(String.fromCharCode(0x00, obj.InputType.TOUCH) + obj.shortToStr(5 + msg.length) + String.fromCharCode(0x02) + msg);
if (Object.keys(obj.TouchArray).length == 0 && obj.touchtimer != null) { clearInterval(obj.touchtimer); obj.touchtimer = null; }
}
@ -342,13 +342,13 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
var MouseMsg = "";
if (Action == obj.KeyAction.SCROLL) MouseMsg = String.fromCharCode(0x00, obj.InputType.MOUSE, 0x00, 0x0C, 0x00, ((Action == obj.KeyAction.DOWN) ? Button : ((Button * 2) & 0xFF)), ((X / 256) & 0xFF), (X & 0xFF), ((Y / 256) & 0xFF), (Y & 0xFF), ((Delta / 256) & 0xFF), (Delta & 0xFF));
else MouseMsg = String.fromCharCode(0x00, obj.InputType.MOUSE, 0x00, 0x0A, 0x00, ((Action == obj.KeyAction.DOWN) ? Button : ((Button * 2) & 0xFF)), ((X / 256) & 0xFF), (X & 0xFF), ((Y / 256) & 0xFF), (Y & 0xFF));
if (obj.Action == obj.KeyAction.NONE) { if (obj.Alternate == 0 || obj.ipad) { obj.Send(MouseMsg); obj.Alternate = 1; } else { obj.Alternate = 0; } } else { obj.Send(MouseMsg); }
if (obj.Action == obj.KeyAction.NONE) { if (obj.Alternate == 0 || obj.ipad) { obj.send(MouseMsg); obj.Alternate = 1; } else { obj.Alternate = 0; } } else { obj.send(MouseMsg); }
}
}
}
obj.GetDisplayNumbers = function () { obj.Send(String.fromCharCode(0x00, 0x0B, 0x00, 0x04)); } // Get Terminal display
obj.SetDisplay = function (number) { obj.Send(String.fromCharCode(0x00, 0x0C, 0x00, 0x06, number >> 8, number & 0xFF)); } // Set Terminal display
obj.GetDisplayNumbers = function () { obj.send(String.fromCharCode(0x00, 0x0B, 0x00, 0x04)); } // Get Terminal display
obj.SetDisplay = function (number) { obj.send(String.fromCharCode(0x00, 0x0C, 0x00, 0x06, number >> 8, number & 0xFF)); } // Set Terminal display
obj.intToStr = function (x) { return String.fromCharCode((x >> 24) & 0xFF, (x >> 16) & 0xFF, (x >> 8) & 0xFF, x & 0xFF); }
obj.shortToStr = function (x) { return String.fromCharCode((x >> 8) & 0xFF, x & 0xFF); }

View file

@ -10,18 +10,19 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.m = module; // This is the inner module (Terminal or Desktop)
module.parent = obj;
obj.meshserver = meshserver;
obj.nodeid = null;
obj.State = 0;
obj.nodeid = null;
obj.socket = null;
obj.connectstate = -1;
obj.tunnelid = Math.random().toString(36).substring(2); // Generate a random client tunnel id
obj.protocol = module.protocol; // 1 = SOL, 2 = KVM, 3 = IDER, 4 = Files, 5 = FileTransfer
obj.onStateChanged = null;
obj.ctrlMsgAllowed = true;
obj.attemptWebRTC = false;
obj.webRtcActive = false;
obj.webSwitchOk = false;
obj.webrtc = null;
obj.webchannel = null;
obj.onStateChanged = null;
obj.webrtc = null;
obj.debugmode = 0;
// Private method
@ -38,8 +39,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.socket.onerror = function (e) { console.error(e); }
obj.socket.onclose = obj.xxOnSocketClosed;
obj.xxStateChange(1);
//obj.meshserver.Send({ action: 'msg', type: 'tunnel', nodeid: obj.nodeid, value: url2 });
obj.meshserver.Send({ action: 'msg', type: 'tunnel', nodeid: obj.nodeid, value: "*/meshrelay.ashx?id=" + obj.tunnelid });
//obj.meshserver.send({ action: 'msg', type: 'tunnel', nodeid: obj.nodeid, value: url2 });
obj.meshserver.send({ action: 'msg', type: 'tunnel', nodeid: obj.nodeid, value: "*/meshrelay.ashx?id=" + obj.tunnelid });
//obj.debug("Agent Redir Start: " + url);
}
@ -53,6 +54,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.xxOnControlCommand = function (msg) {
var controlMsg;
try { controlMsg = JSON.parse(msg); } catch (e) { return; }
if (controlMsg.ctrlChannel != '102938') { obj.xxOnSocketData(msg); return; }
//console.log(controlMsg);
if (obj.webrtc != null) {
if (controlMsg.type == 'answer') {
@ -61,16 +63,19 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.webSwitchOk = true; // Other side is ready for switch over
performWebRtcSwitch();
} else if (controlMsg.type == 'webrtc1') {
obj.socket.send("{\"type\":\"webrtc2\"}"); // Confirm we got end of data marker, indicates data will no longer be received on websocket.
sendCtrlMsg("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc2\"}"); // Confirm we got end of data marker, indicates data will no longer be received on websocket.
} else if (controlMsg.type == 'webrtc2') {
// TODO: Resume/Start sending data over WebRTC
}
}
}
function sendCtrlMsg(x) { if (obj.ctrlMsgAllowed == true) { try { obj.socket.send(x); } catch (e) { } } }
function performWebRtcSwitch() {
if ((obj.webSwitchOk == true) && (obj.webRtcActive == true)) {
obj.socket.send("{\"type\":\"webrtc1\"}"); // Indicate to the other side that data traffic will no longer be sent over websocket.
sendCtrlMsg("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc0\"}"); // Indicate to the meshagent that it can start traffic switchover
sendCtrlMsg("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc1\"}"); // Indicate to the meshagent that data traffic will no longer be sent over websocket.
// TODO: Hold/Stop sending data over websocket
if (obj.onStateChanged != null) { obj.onStateChanged(obj, obj.State); }
}
@ -78,7 +83,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
// Close the WebRTC connection, should be called if a problem occurs during WebRTC setup.
obj.xxCloseWebRTC = function () {
try { obj.webchannel.send("{\"type\":\"close\"}"); } catch (e) { }
sendCtrlMsg("{\"ctrlChannel\":\"102938\",\"type\":\"close\"}");
if (obj.webchannel != null) { try { obj.webchannel.close(); } catch (e) { } obj.webchannel = null; }
if (obj.webrtc != null) { try { obj.webrtc.close(); } catch (e) { } obj.webrtc = null; }
obj.webRtcActive = false;
@ -86,6 +91,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.xxOnMessage = function (e) {
//if (obj.debugmode == 1) { console.log('Recv', e.data); }
//console.log('Recv', e.data, obj.State);
if (obj.State < 3) {
if (e.data == 'c') {
obj.socket.send(obj.protocol);
@ -120,7 +126,6 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
}, obj.xxCloseWebRTC, { mandatory: { OfferToReceiveAudio: false, OfferToReceiveVideo: false } });
}
}
return;
}
}
@ -169,9 +174,9 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
return obj.m.ProcessData(data);
}
obj.Send = function (x) {
obj.send = function (x) {
//obj.debug("Agent Redir Send(" + obj.webRtcActive + ", " + x.length + "): " + rstr2hex(x));
//console.log("Agent Redir Send(" + obj.webRtcActive + ", " + x.length + "): " + rstr2hex(x));
//console.log("Agent Redir Send(" + obj.webRtcActive + ", " + x.length + "): " + ((typeof x == 'string')?x:rstr2hex(x)));
if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) {
if (typeof x == 'string') {
if (obj.debugmode == 1) {
@ -210,7 +215,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.connectstate = -1;
obj.xxCloseWebRTC();
if (obj.socket != null) {
try { if (obj.socket.readyState == 1) { obj.socket.send("{\"type\":\"close\"}"); obj.socket.close(); } } catch (e) { }
try { if (obj.socket.readyState == 1) { sendCtrlMsg("{\"ctrlChannel\":\"102938\",\"type\":\"close\"}"); obj.socket.close(); } } catch (e) { }
obj.socket = null;
}
obj.xxStateChange(0);

View file

@ -81,19 +81,19 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
//var version = parseFloat(obj.acc.substring(4, 11));
//obj.Debug("KVersion: " + version);
obj.state = 1;
obj.Send("RFB 003.008\n");
obj.send("RFB 003.008\n");
}
else if (obj.state == 1 && obj.acc.length >= 1) {
// Getting security options
cmdsize = obj.acc.charCodeAt(0) + 1;
obj.Send(String.fromCharCode(1)); // Send the "None" security type. Since we already authenticated using redirection digest auth, we don't need to do this again.
obj.send(String.fromCharCode(1)); // Send the "None" security type. Since we already authenticated using redirection digest auth, we don't need to do this again.
obj.state = 2;
}
else if (obj.state == 2 && obj.acc.length >= 4) {
// Getting security response
cmdsize = 4;
if (ReadInt(obj.acc, 0) != 0) { return obj.Stop(); }
obj.Send(String.fromCharCode(1)); // Send share desktop flag
obj.send(String.fromCharCode(1)); // Send share desktop flag
obj.state = 3;
}
else if (obj.state == 3 && obj.acc.length >= 24) {
@ -138,11 +138,11 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
if (obj.useZRLE) supportedEncodings += IntToStr(16);
supportedEncodings += IntToStr(0);
obj.Send(String.fromCharCode(2, 0) + ShortToStr((supportedEncodings.length / 4) + 1) + supportedEncodings + IntToStr(-223)); // Supported Encodings + Desktop Size
obj.send(String.fromCharCode(2, 0) + ShortToStr((supportedEncodings.length / 4) + 1) + supportedEncodings + IntToStr(-223)); // Supported Encodings + Desktop Size
// Set the pixel encoding to something much smaller
// obj.Send(String.fromCharCode(0, 0, 0, 0, 16, 16, 0, 1) + ShortToStr(31) + ShortToStr(63) + ShortToStr(31) + String.fromCharCode(11, 5, 0, 0, 0, 0)); // Setup 16 bit color RGB565 (This is the default, so we don't need to set it)
if (obj.bpp == 1) obj.Send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(7) + ShortToStr(7) + ShortToStr(3) + String.fromCharCode(5, 2, 0, 0, 0, 0)); // Setup 8 bit color RGB332
// obj.send(String.fromCharCode(0, 0, 0, 0, 16, 16, 0, 1) + ShortToStr(31) + ShortToStr(63) + ShortToStr(31) + String.fromCharCode(11, 5, 0, 0, 0, 0)); // Setup 16 bit color RGB565 (This is the default, so we don't need to set it)
if (obj.bpp == 1) obj.send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(7) + ShortToStr(7) + ShortToStr(3) + String.fromCharCode(5, 2, 0, 0, 0, 0)); // Setup 8 bit color RGB332
obj.state = 4;
obj.parent.xxStateChange(3);
@ -194,7 +194,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
// Desktop Size (0xFFFFFF21, -223)
obj.canvas.canvas.width = obj.rwidth = obj.width = width;
obj.canvas.canvas.height = obj.rheight = obj.height = height;
obj.Send(String.fromCharCode(3, 0, 0, 0, 0, 0) + ShortToStr(obj.width) + ShortToStr(obj.height)); // FramebufferUpdateRequest
obj.send(String.fromCharCode(3, 0, 0, 0, 0, 0) + ShortToStr(obj.width) + ShortToStr(obj.height)); // FramebufferUpdateRequest
cmdsize = 12;
if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight); }
// obj.Debug("New desktop width: " + obj.width + ", height: " + obj.height);
@ -454,13 +454,13 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
if (obj.focusmode > 0) {
// Request only pixels around the last mouse position
var df = obj.focusmode * 2;
obj.Send(String.fromCharCode(3, 1) + ShortToStr(Math.max(Math.min(obj.ox, obj.mx) - obj.focusmode, 0)) + ShortToStr(Math.max(Math.min(obj.oy, obj.my) - obj.focusmode, 0)) + ShortToStr(df + Math.abs(obj.ox - obj.mx)) + ShortToStr(df + Math.abs(obj.oy - obj.my))); // FramebufferUpdateRequest
obj.send(String.fromCharCode(3, 1) + ShortToStr(Math.max(Math.min(obj.ox, obj.mx) - obj.focusmode, 0)) + ShortToStr(Math.max(Math.min(obj.oy, obj.my) - obj.focusmode, 0)) + ShortToStr(df + Math.abs(obj.ox - obj.mx)) + ShortToStr(df + Math.abs(obj.oy - obj.my))); // FramebufferUpdateRequest
obj.ox = obj.mx;
obj.oy = obj.my;
} else {
// ###END###{DesktopFocus}
// Request the entire screen
obj.Send(String.fromCharCode(3, 1, 0, 0, 0, 0) + ShortToStr(obj.rwidth) + ShortToStr(obj.rheight)); // FramebufferUpdateRequest
obj.send(String.fromCharCode(3, 1, 0, 0, 0, 0) + ShortToStr(obj.rwidth) + ShortToStr(obj.rheight)); // FramebufferUpdateRequest
// ###BEGIN###{DesktopFocus}
}
// ###END###{DesktopFocus}
@ -485,10 +485,10 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
obj.parent.Stop();
}
obj.Send = function (x) {
obj.send = function (x) {
//obj.Debug("KSend(" + x.length + "): " + rstr2hex(x));
//obj.outbytes += x.length;
obj.parent.Send(x);
obj.parent.send(x);
}
/*
@ -552,7 +552,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
return obj.haltEvent(e);
}
obj.sendkey = function (k, d) { obj.Send(String.fromCharCode(4, d, 0, 0) + IntToStr(k)); }
obj.sendkey = function (k, d) { obj.send(String.fromCharCode(4, d, 0, 0) + IntToStr(k)); }
obj.SendCtrlAltDelMsg = function () { obj.sendcad(); }
obj.sendcad = function () {
@ -625,7 +625,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
}
// ###END###{DesktopRotation}
obj.Send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
obj.send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
// ###BEGIN###{DesktopFocus}
// Update focus area if we are in focus mode

View file

@ -253,7 +253,7 @@ var CreateAmtRedirect = function (module) {
}
}
obj.Send = function (x) {
obj.send = function (x) {
if (obj.socket == null || obj.connectstate != 1) return;
if (obj.protocol == 1) { obj.xxSend(String.fromCharCode(0x28, 0x00, 0x00, 0x00) + IntToStrX(obj.amtsequence++) + ShortToStrX(x.length) + x); } else { obj.xxSend(x); }
}

View file

@ -554,8 +554,8 @@ var CreateAmtRemoteTerminal = function (divid) {
}
}
obj.TermSendKeys = function(keys) { obj.parent.Send(keys); }
obj.TermSendKey = function(key) { obj.parent.Send(String.fromCharCode(key)); }
obj.TermSendKeys = function(keys) { obj.parent.send(keys); }
obj.TermSendKey = function(key) { obj.parent.send(String.fromCharCode(key)); }
function _TermMoveUp(linecount) {
var x, y;

View file

@ -37,7 +37,7 @@ var MeshServerCreateControl = function (domain) {
if (obj.onMessage) obj.onMessage(obj, message);
};
obj.Send = function (x) { if (obj.socket != null && obj.connectstate == 1) { obj.socket.send(JSON.stringify(x)); } }
obj.send = function (x) { if (obj.socket != null && obj.connectstate == 1) { obj.socket.send(JSON.stringify(x)); } }
return obj;
}