diff --git a/meshrelay.js b/meshrelay.js index 78ff55f3..e026fc42 100644 --- a/meshrelay.js +++ b/meshrelay.js @@ -28,7 +28,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie } // Check connection id - if (obj.id == null) { try { ws.close(); parent.parent.debug('relay', 'Relay: Connection with no id (' + cleanRemoteAddr(req.ip) + ')'); } catch (e) { console.log(e); } return; } + if ((obj.id == null) || (obj.id.length < 8)) { try { ws.close(); parent.parent.debug('relay', 'Relay: Connection with no id (' + cleanRemoteAddr(req.ip) + ')'); } catch (e) { console.log(e); } return; } // If there is no authentication, drop this connection if ((obj.id.startsWith('meshmessenger/') == false) && (obj.user == null) && (obj.ruserid == null)) { try { ws.close(); parent.parent.debug('relay', 'Relay: Connection with no authentication (' + cleanRemoteAddr(req.ip) + ')'); } catch (e) { console.log(e); } return; } diff --git a/meshuser.js b/meshuser.js index 3410bb6d..49997e8e 100644 --- a/meshuser.js +++ b/meshuser.js @@ -33,6 +33,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use const MESHRIGHT_NOFILES = 1024; const MESHRIGHT_NOAMT = 2048; const MESHRIGHT_DESKLIMITEDINPUT = 4096; + const MESHRIGHT_LIMITEVENTS = 8192; + const MESHRIGHT_CHATNOTIFY = 16384; // Site rights const SITERIGHT_SERVERBACKUP = 1; @@ -362,7 +364,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use { // Renew the authentication cookie try { - console.log(req.ip); ws.send(JSON.stringify({ action: 'authcookie', cookie: parent.parent.encodeCookie({ userid: user._id, domainid: domain.id, ip: cleanRemoteAddr(req.ip) }, parent.parent.loginCookieEncryptionKey), @@ -1604,7 +1605,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use mesh = parent.meshes[node.meshid]; if (mesh) { // Check if this user has rights to do this - if (mesh.links[user._id] == null || ((mesh.links[user._id].rights & MESHRIGHT_REMOTECONTROL) == 0)) return; + if (mesh.links[user._id] == null || ((mesh.links[user._id].rights & MESHRIGHT_CHATNOTIFY) == 0)) return; // Create the server url var httpsPort = ((args.aliasport == null) ? args.port : args.aliasport); // Use HTTPS alias port is specified @@ -2223,8 +2224,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use mesh = parent.meshes[node.meshid]; if (mesh) { // Check if this user has rights to do this - if (mesh.links[user._id] != null && ((mesh.links[user._id].rights & 8) != 0)) { // "Remote Control permission" - + if (mesh.links[user._id] != null && ((mesh.links[user._id].rights & MESHRIGHT_CHATNOTIFY) != 0)) { // Get this device var agent = parent.wsagents[node._id]; if (agent != null) { diff --git a/views/default-min.handlebars b/views/default-min.handlebars index a1d586ac..23c40012 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -9314,7 +9314,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this if (node.conn) { if ((node.conn & 1) != 0) { states.push('Agent'); } if ((node.conn & 2) != 0) { states.push('CIRA'); } - else if ((node.conn & 4) != 0) { states.push('Intel® AMT'); } + else if ((node.conn & 4) != 0) { states.push('AMT'); } if ((node.conn & 8) != 0) { states.push('Relay'); } if ((node.conn & 16) != 0) { states.push('MQTT'); } } @@ -10970,11 +10970,12 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this QV('deskkeys', inputAllowed); QE('deskkeys', deskState == 3); - QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskChatButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskNotifyButton', (browserfullscreen == false) && (currentNode.agent) && (currentNode.agent.id < 5) && (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); + // Display this only if we have Chat & Notify permissions + QV('DeskChatButton', ((meshrights & 16384) != 0) && (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskNotifyButton', ((meshrights & 16384) != 0) && (browserfullscreen == false) && (currentNode.agent) && (currentNode.agent.id < 5) && (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); QV('DeskControlSpan', inputAllowed) QV('deskActionsBtn', (browserfullscreen == false)); QV('deskActionsSettings', (browserfullscreen == false)); @@ -13377,6 +13378,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this x += '
'; x += '
'; x += '
'; + x += '
'; x += ''; if (userid == null) { setDialogMode(2, "Add Users to Device Group", 3, p20showAddMeshUserDialogEx, x); @@ -13403,6 +13405,8 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this if (meshrights & 64) { Q('p20wakedevices').checked = true; } if (meshrights & 128) { Q('p20editnotes').checked = true; } if (meshrights & 8192) { Q('p20limitevents').checked = true; } + if (meshrights & 16384) { Q('p20chatnotify').checked = true; } + } } p20validateAddMeshUserDialog(); @@ -13487,6 +13491,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this if (Q('p20noamt').checked == true) meshadmin += 2048; if (Q('p20remotelimitedinput').checked == true) meshadmin += 4096; if (Q('p20limitevents').checked == true) meshadmin += 8192; + if (Q('p20chatnotify').checked == true) meshadmin += 16384; } if (t == null) { @@ -13522,6 +13527,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this if (((meshrights & 8) != 0) && (meshrights & 2048) != 0) r += ', No Intel® AMT'; if (((meshrights & 8) != 0) && ((meshrights & 4096) != 0) && ((meshrights & 256) == 0)) r += ', Limited Input'; if ((meshrights & 8192) != 0) r += ', Self Events Only'; + if ((meshrights & 16384) != 0) r += ', Chat & Notify'; } r = r.substring(2); if (r == '') { r = 'No Rights'; } diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index 7b40fd03..eecf06f5 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index f11f6723..8d5582b6 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -2299,7 +2299,7 @@ //QV('deskkeys', (currentNode.agent) && (currentNode.agent.id < 5)); //QE('deskkeys', deskState == 3); //QE('DeskToolsButton', online); - QV('DeskToastButton', (currentNode.agent) && (currentNode.agent.id < 5) && (meshrights & 8)); + QV('DeskToastButton', ((meshrights & 16384) != 0) && (currentNode.agent) && (currentNode.agent.id < 5) && (meshrights & 8)); //QE('DeskToastButton', online); QV('deskActionsBtn', meshrights & 8); Q('DeskControl').checked = ((meshrights & 8) != 0); diff --git a/views/default.handlebars b/views/default.handlebars index 113945b3..d8734b17 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -3285,7 +3285,7 @@ if (node.conn) { if ((node.conn & 1) != 0) { states.push('Agent'); } if ((node.conn & 2) != 0) { states.push('CIRA'); } - else if ((node.conn & 4) != 0) { states.push('Intel® AMT'); } + else if ((node.conn & 4) != 0) { states.push('AMT'); } if ((node.conn & 8) != 0) { states.push('Relay'); } if ((node.conn & 16) != 0) { states.push('MQTT'); } } @@ -4941,11 +4941,12 @@ QV('deskkeys', inputAllowed); QE('deskkeys', deskState == 3); - QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskChatButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskNotifyButton', (browserfullscreen == false) && (currentNode.agent) && (currentNode.agent.id < 5) && (inputAllowed) && (mesh.mtype == 2) && online); - QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); + // Display this only if we have Chat & Notify permissions + QV('DeskChatButton', ((meshrights & 16384) != 0) && (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskNotifyButton', ((meshrights & 16384) != 0) && (browserfullscreen == false) && (currentNode.agent) && (currentNode.agent.id < 5) && (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online); + QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online); QV('DeskControlSpan', inputAllowed) QV('deskActionsBtn', (browserfullscreen == false)); QV('deskActionsSettings', (browserfullscreen == false)); @@ -7348,6 +7349,7 @@ x += '
'; x += '
'; x += '
'; + x += '
'; x += ''; if (userid == null) { setDialogMode(2, "Add Users to Device Group", 3, p20showAddMeshUserDialogEx, x); @@ -7374,6 +7376,8 @@ if (meshrights & 64) { Q('p20wakedevices').checked = true; } if (meshrights & 128) { Q('p20editnotes').checked = true; } if (meshrights & 8192) { Q('p20limitevents').checked = true; } + if (meshrights & 16384) { Q('p20chatnotify').checked = true; } + } } p20validateAddMeshUserDialog(); @@ -7458,6 +7462,7 @@ if (Q('p20noamt').checked == true) meshadmin += 2048; if (Q('p20remotelimitedinput').checked == true) meshadmin += 4096; if (Q('p20limitevents').checked == true) meshadmin += 8192; + if (Q('p20chatnotify').checked == true) meshadmin += 16384; } if (t == null) { @@ -7493,6 +7498,7 @@ if (((meshrights & 8) != 0) && (meshrights & 2048) != 0) r += ', No Intel® AMT'; if (((meshrights & 8) != 0) && ((meshrights & 4096) != 0) && ((meshrights & 256) == 0)) r += ', Limited Input'; if ((meshrights & 8192) != 0) r += ', Self Events Only'; + if ((meshrights & 16384) != 0) r += ', Chat & Notify'; } r = r.substring(2); if (r == '') { r = 'No Rights'; }