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

Removed dependency on browser cookies to make the site work.

This commit is contained in:
Ylian Saint-Hilaire 2019-01-28 15:47:54 -08:00
parent e6b05f2b4a
commit e6fc96f3f1
50 changed files with 133 additions and 86 deletions

View file

@ -5,10 +5,11 @@
*/
// Construct a MeshServer object
var CreateAmtRedirect = function (module) {
var CreateAmtRedirect = function (module, authCookie) {
var obj = {};
obj.m = module; // This is the inner module (Terminal or Desktop)
module.parent = obj;
obj.authCookie = authCookie;
obj.State = 0;
obj.socket = null;
// ###BEGIN###{!Mode-Firmware}
@ -40,7 +41,9 @@ var CreateAmtRedirect = function (module) {
obj.pass = pass;
obj.connectstate = 0;
obj.inDataCount = 0;
obj.socket = new WebSocket(window.location.protocol.replace("http", "ws") + "//" + window.location.host + window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + "/webrelay.ashx?p=2&host=" + host + "&port=" + port + "&tls=" + tls + ((user == '*') ? "&serverauth=1" : "") + ((typeof pass === "undefined") ? ("&serverauth=1&user=" + user) : "")); // The "p=2" indicates to the relay that this is a REDIRECTION session
var url = window.location.protocol.replace("http", "ws") + "//" + window.location.host + window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + "/webrelay.ashx?p=2&host=" + host + "&port=" + port + "&tls=" + tls + ((user == '*') ? "&serverauth=1" : "") + ((typeof pass === "undefined") ? ("&serverauth=1&user=" + user) : ""); // The "p=2" indicates to the relay that this is a REDIRECTION session
if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
obj.socket = new WebSocket(url);
obj.socket.onopen = obj.xxOnSocketConnected;
obj.socket.onmessage = obj.xxOnMessage;
obj.socket.onclose = obj.xxOnSocketClosed;