More work on IP-KVM support.

Ylian Saint-Hilaire committed Dec 5, 2021 at 14:33 UTC 718f58c5dc21a210a35505777bb8b449c868655d
4 files changed +160 -44
meshipkvm.js
+85 -1
@@ -9,10 +9,12 @@
9 function CreateIPKVMManager(parent) {
10 const obj = {};
11 const managedGroups = {} // meshid --> Manager
12 + const managedPorts = {} // nodeid --> PortInfo
13
14 // Subscribe for mesh creation events
15 parent.AddEventDispatch(['server-createmesh', 'server-deletemesh'], obj);
16 obj.HandleEvent = function (source, event, ids, id) {
17 + console.log();
18 if ((event != null) && (event.action == 'createmesh') && (event.mtype == 4)) {
19 // Start managing this new device group
20 startManagement(parent.webserver.meshes[event.meshid]);
@@ -36,6 +38,7 @@ function CreateIPKVMManager(parent) {
38 if (mesh.kvm.model == 1) { // Raritan KX III
39 const manager = CreateRaritanKX3Manager(host, port, mesh.kvm.user, mesh.kvm.pass);
40 manager.meshid = mesh._id;
41 + manager.domainid = mesh._id.split('/')[1];
42 managedGroups[mesh._id] = manager;
43 manager.onStateChanged = onStateChanged;
44 manager.onPortsChanged = onPortsChanged;
@@ -46,7 +49,18 @@ function CreateIPKVMManager(parent) {
49 // Stop managing a IP KVM device
50 function stopManagement(meshid) {
51 const manager = managedGroups[meshid];
49 - if (manager != null) { delete managedGroups[meshid]; manager.stop(); }
52 + if (manager != null) {
53 + // Remove all managed ports
54 + for (var i = 0; i < manager.ports.length; i++) {
55 + const port = manager.ports[i];
56 + const nodeid = generateIpKvmNodeId(manager.meshid, port.PortId, manager.domainid);
57 + delete managedPorts[nodeid]; // Remove the managed port
58 + }
59 +
60 + // Remove the manager
61 + delete managedGroups[meshid];
62 + manager.stop();
63 + }
64 }
65
66 // Called when a KVM device changes state
@@ -62,12 +76,82 @@ function CreateIPKVMManager(parent) {
76 function onPortsChanged(sender, updatedPorts) {
77 for (var i = 0; i < updatedPorts.length; i++) {
78 const port = sender.ports[updatedPorts[i]];
79 + const nodeid = generateIpKvmNodeId(sender.meshid, port.PortId, sender.domainid);
80 if ((port.Status == 1) && (port.Class == 'KVM')) {
81 console.log(port.PortNumber + ', ' + port.PortId + ', ' + port.Name + ', ' + port.Type + ', ' + ((port.StatAvailable == 0) ? 'Idle' : 'Connected'));
82 + if ((managedPorts[nodeid] == null) || (managedPorts[nodeid].name != port.Name)) {
83 + parent.db.Get(nodeid, function (err, nodes) {
84 + if ((err != null) || (nodes == null)) return;
85 + const mesh = parent.webserver.meshes[sender.meshid];
86 + if (nodes.length == 0) {
87 + // The device does not exist, create it
88 + const device = { type: 'node', mtype: 4, _id: nodeid, icon: 1, meshid: sender.meshid, name: port.Name, rname: port.Name, domain: sender.domainid, porttype: port.Type, portid: port.PortId, portnum: port.PortNumber };
89 + parent.db.Set(device);
90 +
91 + // Event the new node
92 + parent.DispatchEvent(parent.webserver.CreateMeshDispatchTargets(sender.meshid, [nodeid]), obj, { etype: 'node', action: 'addnode', nodeid: nodeid, node: device, msgid: 57, msgArgs: [port.Name, mesh.name], msg: ('Added device ' + port.Name + ' to device group ' + mesh.name), domain: sender.domainid });
93 + } else {
94 + // The device exists, update it
95 + var changed = false;
96 + const device = nodes[0];
97 + if (device.rname != port.Name) { device.rname = port.Name; changed = true; } // Update the device port name
98 + if ((mesh.flags) && (mesh.flags & 2) && (device.name != port.Name)) { device.name = port.Name; changed = true; } // Sync device name to port name
99 + if (changed) {
100 + // Update the database and event the node change
101 + parent.db.Set(device);
102 + parent.DispatchEvent(parent.webserver.CreateMeshDispatchTargets(sender.meshid, [nodeid]), obj, { etype: 'node', action: 'changenode', nodeid: nodeid, node: device, domain: sender.domainid, nolog: 1 });
103 + }
104 + }
105 +
106 + // Set the connectivity state if needed
107 + if (managedPorts[nodeid] == null) {
108 + parent.SetConnectivityState(sender.meshid, nodeid, Date.now(), 1, 1, null, null);
109 + managedPorts[nodeid] = { name: port.Name, busy: false };
110 + }
111 +
112 + // Update busy state
113 + const portInfo = managedPorts[nodeid];
114 + if (portInfo.busy != (port.StatAvailable != 0)) {
115 + console.log('Busy state', (port.StatAvailable != 0));
116 + }
117 + });
118 + } else {
119 + // Update busy state
120 + const portInfo = managedPorts[nodeid];
121 + if (portInfo.busy != (port.StatAvailable != 0)) {
122 + console.log('Busy state', (port.StatAvailable != 0));
123 + }
124 + }
125 + } else {
126 + if (managedPorts[nodeid] != null) {
127 + // This port is no longer connected
128 + parent.ClearConnectivityState(sender.meshid, nodeid, 1, null, null);
129 +
130 + // If the device group policy is set to auto-remove devices, remove it now
131 + if ((mesh.flags) && (mesh.flags & 1)) { // Auto-remove devices
132 + parent.db.Remove(nodeid); // Remove node with that id
133 + parent.db.Remove('nt' + nodeid); // Remove notes
134 + parent.db.Remove('lc' + nodeid); // Remove last connect time
135 + parent.db.Remove('al' + nodeid); // Remove error log last time
136 + parent.db.RemoveAllNodeEvents(nodeid); // Remove all events for this node
137 + parent.db.removeAllPowerEventsForNode(nodeid); // Remove all power events for this node
138 +
139 + // Event node deletion
140 + parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(sender.meshid, [nodeid]), obj, { etype: 'node', action: 'removenode', nodeid: nodeid, domain: domain.id, nolog: 1 });
141 + }
142 +
143 + // Remove the managed port
144 + delete managedPorts[nodeid];
145 + }
146 }
147 }
148 }
149
150 + // Generate the nodeid from the device group and device identifier
151 + function generateIpKvmNodeId(meshid, portid, domainid) {
152 + return 'node/' + domainid + '/' + parent.crypto.createHash('sha384').update(Buffer.from(meshid + '/' + portid)).digest().toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
153 + }
154 +
155 return obj;
156 }
157
meshuser.js
+1 -1
@@ -2528,7 +2528,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2528 parent.parent.DispatchEvent(targets, obj, event);
2529
2530 // Event the device group creation
2531 - var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msgid: 76, msgArgs: [command.meshname], msg: 'Device group created: ' + command.meshname, domain: domain.id, creation: mesh.creation, creatorid: mesh.creatorid, creatorname: mesh.creatorname, flags: mesh.flags, consent: mesh.consent };
2531 + var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, mtype: command.meshtype, mesh: parent.CloneSafeMesh(mesh), action: 'createmesh', msgid: 76, msgArgs: [command.meshname], msg: 'Device group created: ' + command.meshname, domain: domain.id };
2532 parent.parent.DispatchEvent(['*', 'server-createmesh', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
2533
2534 // Log in the auth log
views/default-mobile.handlebars
+18 -12
@@ -1765,8 +1765,8 @@
1765 }
1766 case 'createmesh': {
1767 // A new mesh was created
1768 - if ((meshes[message.event.meshid] == null) && ((userinfo.manageAllDeviceGroups) || (message.event.links[userinfo._id] != null))) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
1769 - meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
1768 + if ((meshes[message.event.meshid] == null) && ((userinfo.manageAllDeviceGroups) || (message.event.mesh.links[userinfo._id] != null))) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
1769 + meshes[message.event.meshid] = message.event.mesh;
1770 mainUpdate(4 + 128);
1771 meshserver.send({ action: 'files' });
1772 }
@@ -3218,7 +3218,7 @@
3218 var states = [];
3219 if (node.state > 0 && node.state < powerStatetable.length) state.push(powerStatetable[node.state]);
3220 if (node.conn) {
3221 - if ((node.conn & 1) != 0) { states.push('<span>' + "Agent" + '</span>'); }
3221 + if ((node.conn & 1) != 0) { if (node.mtype == 4) { states.push('<span>' + ((node.mtype == 4)?"IP-KVM":"Agent") + '</span>'); } else { states.push('<span>' + "IP KVM" + '</span>'); } }
3222 if ((node.conn & 2) != 0) { states.push('<span>' + "CIRA" + '</span>'); }
3223 else if ((node.conn & 4) != 0) { states.push('<span>' + "Intel&reg; AMT" + '</span>'); }
3224 if ((node.conn & 8) != 0) { states.push('<span>' + "Relay" + '</span>'); }
@@ -3356,7 +3356,7 @@
3356 if (node.rname != null) { x += addDeviceAttribute('<span>' + "Name" + '</span>', '<span>' + EscapeHtml(node.rname) + '</span>'); }
3357
3358 // Attribute: Host
3359 - if ((features & 1) == 0) { // If not WAN-only, local hostname is in use
3359 + if (((features & 1) == 0) && (node.mtype != 4)) { // If not WAN-only, local hostname is in use
3360 if ((meshrights & 4) != 0) {
3361 if (node.host) {
3362 x += addDeviceAttribute("Hostname", '<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>' + EscapeHtml(node.host) + '</span>');
@@ -3376,6 +3376,12 @@
3376 x += addDeviceAttribute("Description", description);
3377 }
3378
3379 + // IP-KVM information
3380 + if (node.mtype == 4) {
3381 + if (node.portnum) { x += addDeviceAttribute("Port Number", node.portnum); }
3382 + if (node.porttype) { x += addDeviceAttribute("Port Type", node.porttype); }
3383 + }
3384 +
3385 // Attribute: Mesh Agent
3386 if ((node.agent != null) && (node.agent.id != null) && (node.mtype == 3)) {
3387 if (node.agent.id == 4) { x += addDeviceAttribute("Device Type", "Windows"); }
@@ -3476,7 +3482,7 @@
3482 var connectivity = node.conn;
3483 if (connectivity && connectivity > 1) {
3484 var cstate = [];
3479 - if ((node.conn & 1) != 0) cstate.push('<span>' + "Agent" + '</span>');
3485 + if ((node.conn & 1) != 0) cstate.push('<span>' + ((node.mtype == 4) ? "IP-KVM" : "Agent") + '</span>');
3486 if ((node.conn & 2) != 0) cstate.push('<span>' + "Intel&reg; AMT CIRA" + '</span>');
3487 else if ((node.conn & 4) != 0) cstate.push('<span>' + "Intel&reg; AMT" + '</span>');
3488 if ((node.conn & 8) != 0) cstate.push('<span>' + "Agent Relay" + '</span>');
@@ -3488,7 +3494,7 @@
3494 var groupingTags = '<i>' + "None" + '</i>';
3495 if (node.tags != null) { groupingTags = ''; for (var i in node.tags) { groupingTags += '<span style="background-color:lightgray;padding:3px;border-radius:5px">' + EscapeHtml(node.tags[i]) + '</span> '; } }
3496 if ((meshrights & 4) != 0) {
3491 - x += addDeviceAttribute("Tags", '<span onclick=showEditNodeValueDialog(3) style=line-height:26px;cursor:pointer;color:black>' + groupingTags + '</span>');
3497 + x += addDeviceAttribute("Tags", '<span onclick=showEditNodeValueDialog(3) style=cursor:pointer;color:black>' + groupingTags + '</span>');
3498 } else {
3499 x += addDeviceAttribute("Tags", '<span style=line-height:26px;color:black>' + groupingTags + '</span>');
3500 }
@@ -3536,7 +3542,7 @@
3542 // Set the node power state
3543 var powerstate = PowerStateStr(node.state);
3544 //if (node.state == 0) { powerstate = 'Unknown State'; }
3539 - if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "Mesh Agent"; }
3545 + if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += ((mesh.mtype == 4) ? "IP-KVM" : "Mesh Agent"); }
3546 if ((connectivity & 2) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "Intel&reg; AMT connected"; }
3547 else if ((connectivity & 4) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "Intel&reg; AMT detected"; }
3548 if ((connectivity & 16) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "MQTT channel connected"; }
@@ -3600,17 +3606,17 @@
3606 if ((currentDevicePanel != 1) &&
3607 (currentNode != null) &&
3608 ((meshrights & 8) || (meshrights & 256)) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 65536) == 0)) &&
3603 - (((currentNode.agent == null) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 1)))
3609 + (((currentNode.agent == null) && (currentNode.intelamt) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 1)))
3610 ) { menus.push({ n: "Desktop", f: 'setupDeviceMenu(1)' }); }
3611
3612 if ((currentDevicePanel != 5) &&
3613 (currentNode != null) &&
3614 ((meshrights & 8) || (meshrights & 256)) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0)) &&
3609 - (((currentNode.agent == null) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 2)))
3615 + (((currentNode.agent == null) && (currentNode.intelamt) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 2)))
3616 ) { menus.push({ n: "Terminal", f: 'setupDeviceMenu(5)' }); }
3617
3612 - if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0)) && ((currentNode.mtype != 1) && (currentNode.agent.caps & 4))) { menus.push({ n: "Files", f: 'setupDeviceMenu(2)' }); }
3613 - if ((currentDevicePanel != 3) && (currentNode != null) && (currentNode.mtype != 3) && ((meshrights & 1048576) != 0)) { menus.push({ n: "Details", f: 'setupDeviceMenu(3)' }); }
3618 + if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0)) && ((currentNode.mtype != 1) && (currentNode.agent) && (currentNode.agent.caps & 4))) { menus.push({ n: "Files", f: 'setupDeviceMenu(2)' }); }
3619 + if ((currentDevicePanel != 3) && (currentNode != null) && (currentNode.mtype < 3) && ((meshrights & 1048576) != 0)) { menus.push({ n: "Details", f: 'setupDeviceMenu(3)' }); }
3620 if ((currentDevicePanel != 4) && (currentNode != null) && (meshrights & 0x00000010) && (currentNode.mtype == 2)) { menus.push({ n: "Console", f: 'setupDeviceMenu(4)' }); }
3621 updateFooterMenu(menus);
3622 updateCurrentUrl();
@@ -5144,7 +5150,7 @@
5150 }
5151
5152 function p13setActions() {
5147 - var advancedFeatures = (currentNode.agent.id != 14); // Reduct file feature on some devices.
5153 + var advancedFeatures = ((currentNode.agent) && (currentNode.agent.id != 14)); // Reduct file feature on some devices.
5154 if (p13filetree == null) {
5155 QE('p13DeleteFileButton', false);
5156 QE('p13NewFolderButton', false);
views/default.handlebars
+56 -30
@@ -2984,8 +2984,8 @@
2984 }
2985 case 'createmesh': {
2986 // A new mesh was created
2987 - if ((meshes[message.event.meshid] == null) && ((serverinfo.manageAllDeviceGroups) || (message.event.links[userinfo._id] != null))) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
2988 - meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links, creation: message.event.creation, creatorid: message.event.creatorid, creatorname: message.event.creatorname, flags: message.event.flags, consent: message.event.consent };
2987 + if ((meshes[message.event.meshid] == null) && ((serverinfo.manageAllDeviceGroups) || (message.event.mesh.links[userinfo._id] != null))) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
2988 + meshes[message.event.meshid] = message.event.mesh;
2989 mainUpdate(4 + 128 + 8192 + 16384);
2990 meshserver.send({ action: 'files' });
2991 }
@@ -4366,7 +4366,11 @@
4366 } else if (view == 2) {
4367 var states = [];
4368 if (node.conn) {
4369 - if ((node.conn & 1) != 0) { states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>'); }
4369 + if (node.mtype == 4) {
4370 + if ((node.conn & 1) != 0) { states.push('<span title="' + "IP-KVM port is connected and ready for use." + '">' + "IP-KVM" + '</span>'); }
4371 + } else {
4372 + if ((node.conn & 1) != 0) { states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>'); }
4373 + }
4374 if ((node.conn & 2) != 0) { states.push('<span title="' + "Intel&reg; AMT CIRA is connected and ready for use." + '">' + "CIRA" + '</span>'); }
4375 else if ((node.conn & 4) != 0) { states.push('<span title="' + "Intel&reg; AMT is routable." + '">' + "AMT" + '</span>'); }
4376 if ((node.conn & 8) != 0) { states.push('<span title="' + "Mesh agent is reachable using another agent as relay." + '">' + "Relay" + '</span>'); }
@@ -5130,7 +5134,13 @@
5134 var states = [];
5135 if (node.state > 0 && node.state < powerStatetable.length) state.push(powerStatetable[node.state]);
5136 if (node.conn) {
5133 - if ((node.conn & 1) != 0) { states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>'); }
5137 + if ((node.conn & 1) != 0) {
5138 + if (node.mtype == 4) {
5139 + states.push('<span title="' + "IP KVM port is up and ready for use." + '">' + "IP-KVM" + '</span>');
5140 + } else {
5141 + states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>');
5142 + }
5143 + }
5144 if ((node.conn & 2) != 0) { states.push('<span title="' + "Intel&reg; AMT CIRA is connected and ready for use." + '">' + "CIRA" + '</span>'); }
5145 else if ((node.conn & 4) != 0) { states.push('<span title="' + "Intel&reg; AMT is routable." + '">' + "AMT" + '</span>'); }
5146 if ((node.conn & 8) != 0) { states.push('<span title="' + "Mesh agent is reachable using another agent as relay." + '">' + "Relay" + '</span>'); }
@@ -6659,7 +6669,7 @@
6669 if ((node.rname != null) && (node.name != node.rname)) { x += addDeviceAttribute('<span title="' + "The name of this computer as set in the operating system" + '">' + "OS Name" + '</span>', '<span title="' + "The name of this computer as set in the operating system" + '">' + EscapeHtml(node.rname) + '</span>'); }
6670
6671 // Attribute: Host
6662 - if ((features & 1) == 0) { // If not WAN-only, local hostname is in use
6672 + if (((features & 1) == 0) && (node.mtype != 4)) { // If not WAN-only, local hostname is in use
6673 x += addDeviceAttribute("Hostname", addLinkConditional('<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>' + (node.host?EscapeHtml(node.host):('<i>' + "None" + '</i>')) + '</span>', 'showEditNodeValueDialog(1)', meshrights & 4));
6674 }
6675
@@ -6671,6 +6681,12 @@
6681 x += addDeviceAttribute("Description", description);
6682 }
6683
6684 + // IP-KVM information
6685 + if (node.mtype == 4) {
6686 + if (node.portnum) { x += addDeviceAttribute("Port Number", node.portnum); }
6687 + if (node.porttype) { x += addDeviceAttribute("Port Type", node.porttype); }
6688 + }
6689 +
6690 // Attribute: Mesh Agent
6691 if ((node.agent != null) && (node.agent.id != null) && (node.mtype == 3)) {
6692 if (node.agent.id == 4) { x += addDeviceAttribute("Device Type", "Windows"); }
@@ -6854,20 +6870,22 @@
6870
6871 x += '</table><br />';
6872 // Show action button, only show if we have permissions 4, 8, 64
6857 - if (((meshrights & (4 + 8 + 64)) != 0) && (node.mtype != 3) && ((node.agent == null) || (node.agent.id != 34))) { x += '<input type=button value="' + "Actions" + '" title="' + "Perform power actions on the device" + '" onclick=deviceActionFunction() />'; }
6873 + if (((meshrights & (4 + 8 + 64)) != 0) && (node.mtype < 3) && ((node.agent == null) || (node.agent.id != 34))) { x += '<input type=button value="' + "Actions" + '" title="' + "Perform power actions on the device" + '" onclick=deviceActionFunction() />'; }
6874 x += '<input type=button value="' + "Notes" + '" title="' + "View notes about this device" + '" onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponentEx(node._id) + '") />';
6875 x += '<input type=button value="' + "Log Event" + '" title="' + "Write an event for this device" + '" onclick=writeDeviceEvent("' + encodeURIComponentEx(node._id) + '") />';
6860 - if ((meshrights & 8) && ((connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0)))) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
6861 - //if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
6862 - if ((meshrights & 8) && (connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0))) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
6863 - if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) {
6864 - for (var i in serverinfo.altmessenging) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging[i].name) + '" onclick=altDeviceChat(event,' + i + ') />'; }
6865 - }
6866 - if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && ((meshrights & 0x80008) == 0x80008) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 0x1000) == 0))) {
6867 - x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />';
6868 - QV('DeskGuestShareButton', true);
6869 - } else {
6870 - QV('DeskGuestShareButton', false);
6876 + if (node.mtype != 4) {
6877 + if ((meshrights & 8) && ((connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0)))) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
6878 + //if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
6879 + if ((meshrights & 8) && (connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0))) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
6880 + if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) {
6881 + for (var i in serverinfo.altmessenging) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging[i].name) + '" onclick=altDeviceChat(event,' + i + ') />'; }
6882 + }
6883 + if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && ((meshrights & 0x80008) == 0x80008) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 0x1000) == 0))) {
6884 + x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />';
6885 + QV('DeskGuestShareButton', true);
6886 + } else {
6887 + QV('DeskGuestShareButton', false);
6888 + }
6889 }
6890
6891 // Custom UI
@@ -6892,7 +6910,7 @@
6910
6911 // Show bottom buttons
6912 x = '<div class="p10html3right">';
6895 - if ((meshrights & 1) != 0) { // MESHRIGHT_EDITMESH
6913 + if (((meshrights & 1) != 0) && (node.mtype != 4)) { // MESHRIGHT_EDITMESH
6914 // TODO: Show change group only if there is another mesh of the same type.
6915 x += '&nbsp;<a href=# onclick=p10showChangeGroupDialog(["' + node._id + '"]) title="' + "Move this device to a different device group" + '">' + "Change Group" + '</a>';
6916 }
@@ -6978,7 +6996,14 @@
6996 //if (node.state == 0) { powerstate = 'Unknown State'; }
6997 var agentPrivilages = '';
6998 if ((node.agent != null) && (node.agent.root === false)) { agentPrivilages = ', <span title="' + "Agent is running on remote device with reduced privilages." + '">' + "Restricted" + '</span>'; }
6981 - if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "Agent connected" + '">' + "Agent connected" + '</span>' + agentPrivilages; }
6999 + if ((connectivity & 1) != 0) {
7000 + if (powerstate.length > 0) { powerstate += '<br/>'; }
7001 + if (node.mtype == 4) {
7002 + powerstate += '<span style=font-size:12px title="' + "IP-KVM port connected" + '">' + "IP-KVM port connected" + '</span>' + agentPrivilages;
7003 + } else {
7004 + powerstate += '<span style=font-size:12px title="' + "Agent connected" + '">' + "Agent connected" + '</span>' + agentPrivilages;
7005 + }
7006 + }
7007 if ((connectivity & 2) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "Intel&reg; AMT connected" + '">' + "Intel&reg; AMT connected" + '</span>'; }
7008 else if ((connectivity & 4) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "Intel&reg; AMT detected" + '">' + "Intel&reg; AMT detected" + '</span>'; }
7009 if ((connectivity & 16) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "MQTT connected" + '">' + "MQTT channel connected" + '</span>'; }
@@ -7002,13 +7027,13 @@
7027 // Show or hide the tabs
7028 // mesh.mtype: 1 = Intel AMT only, 2 = Mesh Agent, 3 = Local Device
7029 // node.agent.caps (bitmask): 1 = Desktop, 2 = Terminal, 4 = Files, 8 = Console
7005 - QV('MainDevDesktop', desktopAccess && ((((node.agent == null) && ((typeof node.intelamt.sku !== 'number') || ((node.intelamt.sku & 8) != 0)))
7030 + QV('MainDevDesktop', desktopAccess && ((((node.agent == null) && (node.intelamt != null) && ((typeof node.intelamt.sku !== 'number') || ((node.intelamt.sku & 8) != 0)))
7031 || ((node.agent != null) && ((node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2)))))
7032 && ((meshrights & 8) || (meshrights & 256)))
7033 );
7009 - QV('MainDevTerminal', (((node.agent == null) && (node.intelamt != null)) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
7034 + QV('MainDevTerminal', (((node.agent == null) && (node.intelamt != null)) || ((node.agent) && (node.agent.caps == null)) || ((node.agent) && ((node.agent.caps & 2) != 0)) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
7035 QV('MainDevFiles', (node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 4) != 0) && (meshrights & 8) && fileAccess);
7011 - QV('MainDevInfo', (node.mtype != 3) & ((meshrights & 1048576) != 0));
7036 + QV('MainDevInfo', (node.mtype < 3) && ((meshrights & 1048576) != 0));
7037 QV('MainDevAmt', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8) && amtAccess);
7038 QV('MainDevConsole', (consoleRights && ((node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 8) != 0))) && (meshrights & 8));
7039 QV('MainDevPlugins', false);
@@ -11564,6 +11589,7 @@
11589 if (mname.length == 0) { mname = '<i>' + "None" + '</i>'; }
11590 if ((meshrights & 1) != 0) { mname = '<span tabindex=0 title="' + "Click here to edit the device group name" + '" onclick=p20editmesh(1) onkeyup="if (event.key == \'Enter\') p20editmesh(1)" style=cursor:pointer>' + mname + ' <img class=hoverButton src="images/link5.png" /></span>'; }
11591 QH('p20meshName', mname);
11592 + QV('MeshSummary', (currentMesh.mtype != 4));
11593
11594 var meshtype = format("Unknown #{0}", currentMesh.mtype);
11595 if (currentMesh.mtype == 1) meshtype = "Intel&reg; AMT only, no agent";
@@ -11597,11 +11623,11 @@
11623 if (currentMesh.creation != null) { x += addHtmlValue("Creation Time", printDateTime(new Date(currentMesh.creation))); }
11624
11625 // Display features
11600 - if (currentMesh.mtype < 3) {
11626 + if (currentMesh.mtype != 3) {
11627 var meshFeatures = [];
11628 if (currentMesh.flags) {
11629 if (currentMesh.flags & 1) { meshFeatures.push("Auto-Remove"); }
11604 - if (currentMesh.flags & 2) { meshFeatures.push("Hostname Sync"); }
11630 + if (currentMesh.flags & 2) { meshFeatures.push((currentMesh.mtype == 4)?"Port Name Sync":"Hostname Sync"); }
11631 if ((serverinfo.devGroupSessionRecording == 1) && (currentMesh.flags & 4)) { meshFeatures.push("Record Sessions"); }
11632 }
11633 if ((typeof currentMesh.expireDevs == 'number') && (currentMesh.expireDevs > 0)) { meshFeatures.push("Remove inactive"); }
@@ -12036,11 +12062,11 @@
12062 if (xxdialogMode) return;
12063 var flags = (currentMesh.flags)?currentMesh.flags:0, x = '', expire = 0;
12064 if ((typeof currentMesh.expireDevs == 'number') && (currentMesh.expireDevs > 0)) { expire = currentMesh.expireDevs; if (expire > 2000) { expire = 2000; } }
12039 - if (serverinfo.devGroupSessionRecording == 1) {
12065 + if ((serverinfo.devGroupSessionRecording == 1) && (currentMesh.mtype != 4)) {
12066 x += '<div><label><input type=checkbox id=d20flag4 onchange=p20editmeshfeaturesValidate() ' + ((flags & 4) ? 'checked' : '') + '>' + "Record sessions" + '</label><br></div>';
12067 }
12042 - if (currentMesh.mtype == 2) {
12043 - x += '<div><label><input type=checkbox id=d20flag2 onchange=p20editmeshfeaturesValidate() ' + ((flags & 2) ? 'checked' : '') + '>' + "Sync server device name to hostname" + '</label><br></div>';
12068 + if ((currentMesh.mtype == 2) || (currentMesh.mtype == 4)) {
12069 + x += '<div><label><input type=checkbox id=d20flag2 onchange=p20editmeshfeaturesValidate() ' + ((flags & 2) ? 'checked' : '') + '>' + ((currentMesh.mtype == 4)?"Sync server device name to port name":"Sync server device name to hostname") + '</label><br></div>';
12070 x += '<div><label><input type=checkbox id=d20flag1 onchange=p20editmeshfeaturesValidate() ' + ((flags & 1) ? 'checked' : '') + '>' + "Remove device on disconnect" + '</label><br></div>';
12071 }
12072 x += '<div><label><input type=checkbox id=d20expireDevice onchange=p20editmeshfeaturesValidate() ' + ((expire > 0) ? 'checked' : '') + '>' + "Automatically remove inactive devices" + '</label><br></div>';
@@ -12060,7 +12086,7 @@
12086
12087 function p20editmeshfeaturesValidate() {
12088 var flags = 0, ok = true;
12063 - if ((currentMesh.mtype == 2) && (Q('d20flag1').checked)) { flags += 1; }
12089 + if (((currentMesh.mtype == 2) || (currentMesh.mtype == 4)) && (Q('d20flag1').checked)) { flags += 1; }
12090 QE('d20expireDevice', (flags & 1) == 0);
12091 var x = ((flags & 1) == 0) && Q('d20expireDevice').checked;
12092 QV('d20expireDeviceDev', x);
@@ -12070,11 +12096,11 @@
12096
12097 function p20editmeshfeaturesEx() {
12098 var flags = 0;
12073 - if (currentMesh.mtype == 2) {
12099 + if ((currentMesh.mtype == 2) || (currentMesh.mtype == 4)) {
12100 if (Q('d20flag1').checked) { flags += 1; }
12101 if (Q('d20flag2').checked) { flags += 2; }
12102 }
12077 - if (serverinfo.devGroupSessionRecording == 1) { if (Q('d20flag4').checked) { flags += 4; } }
12103 + if ((serverinfo.devGroupSessionRecording == 1) && (currentMesh.mtype != 4)) { if (Q('d20flag4').checked) { flags += 4; } }
12104 var expireDevs = 0;
12105 if (((flags & 1) == 0) && Q('d20expireDevice').checked) { expireDevs = parseInt(Q('d20expireDeviceDays').value); }
12106 meshserver.send({ action: 'editmesh', meshid: currentMesh._id, flags: flags, expireDevs: expireDevs });