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:
parent
e6b05f2b4a
commit
e6fc96f3f1
50 changed files with 133 additions and 86 deletions
|
@ -5,11 +5,12 @@
|
|||
*/
|
||||
|
||||
// Construct a MeshServer agent direction object
|
||||
var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||
var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, authCookie) {
|
||||
var obj = {};
|
||||
obj.m = module; // This is the inner module (Terminal or Desktop)
|
||||
module.parent = obj;
|
||||
obj.meshserver = meshserver;
|
||||
obj.authCookie = authCookie;
|
||||
obj.State = 0;
|
||||
obj.nodeid = null;
|
||||
obj.socket = null;
|
||||
|
@ -31,6 +32,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
|||
obj.Start = function (nodeid) {
|
||||
var url2, url = window.location.protocol.replace("http", "ws") + "//" + window.location.host + window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + "/meshrelay.ashx?id=" + obj.tunnelid;
|
||||
//if (serverPublicNamePort) { url2 = window.location.protocol.replace("http", "ws") + "//" + serverPublicNamePort + "/meshrelay.ashx?id=" + obj.tunnelid; } else { url2 = url; }
|
||||
if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
|
||||
obj.nodeid = nodeid;
|
||||
obj.connectstate = 0;
|
||||
obj.socket = new WebSocket(url);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
* @version v0.0.1
|
||||
*/
|
||||
|
||||
var MeshServerCreateControl = function (domain) {
|
||||
var MeshServerCreateControl = function (domain, authCookie) {
|
||||
var obj = {};
|
||||
obj.State = 0;
|
||||
obj.connectstate = 0;
|
||||
obj.pingTimer = null;
|
||||
obj.authCookie = authCookie;
|
||||
|
||||
obj.xxStateChange = function (newstate, errCode) {
|
||||
if (obj.State == newstate) return;
|
||||
|
@ -20,7 +21,9 @@ var MeshServerCreateControl = function (domain) {
|
|||
obj.Start = function () {
|
||||
if (obj.connectstate != 0) return;
|
||||
obj.connectstate = 0;
|
||||
obj.socket = new WebSocket(window.location.protocol.replace("http", "ws") + "//" + window.location.host + domain + "control.ashx");
|
||||
var url = window.location.protocol.replace("http", "ws") + "//" + window.location.host + domain + "control.ashx";
|
||||
if (obj.authCookie && (obj.authCookie != '')) { url += '?auth=' + obj.authCookie; }
|
||||
obj.socket = new WebSocket(url);
|
||||
obj.socket.onopen = function (e) { obj.connectstate = 1; }
|
||||
obj.socket.onmessage = obj.xxOnMessage;
|
||||
obj.socket.onclose = function(e) { obj.Stop(e.code); }
|
||||
|
@ -42,6 +45,7 @@ var MeshServerCreateControl = function (domain) {
|
|||
var message;
|
||||
try { message = JSON.parse(e.data); } catch (e) { return; }
|
||||
if ((typeof message != 'object') || (message.action == 'pong')) { return; }
|
||||
if (message.action == 'close') { if (message.msg) { console.log(message.msg); } obj.Stop(message.cause); return; }
|
||||
if (obj.onMessage) obj.onMessage(obj, message);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue