Updated MeshCentral Router, support mapping name in URL, #3979

Ylian Saint-Hilaire committed May 16, 2022 at 16:53 UTC d6ad242ef453e4256041fc457b0ea46eec2cc378
2 files changed +11 -6
agents/MeshCentralRouter.exe
Binary files a/agents/MeshCentralRouter.exe and b/agents/MeshCentralRouter.exe differ
views/default.handlebars
+11 -6
@@ -2723,6 +2723,7 @@
2723 if (message.tcpport != null) { url += ('&protocol=1&remoteport=' + message.tcpport); }
2724 if (message.localRelay) { url += '&local=1'; }
2725 if (message.localport) { url += '&localport=' + message.localport; }
2726 + if (message.name != null) { url += ('&name=' + encodeURIComponentEx(message.name)); }
2727 if (message.ip != null) { url += ('&remoteip=' + message.ip); }
2728 url += ('&appid=' + message.protocol + '&autoexit=1'); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP, 6 = MCRDesktop, 7 = MCRFiles
2729 console.log(url);
@@ -8012,29 +8013,33 @@
8013
8014 function p10MCRouter(nodeid, protocol, port, addr, localport) {
8015 var node = getNodeFromId(nodeid);
8016 + var mesh = meshes[node.meshid];
8017 if ((protocol == 3) && (port == null)) { if (node.rdpport != null) { port = node.rdpport; } else { port = 3389; } } // Adjust RDP port if needed
8016 - if (node.mtype == 3) { var mesh = meshes[node.meshid]; if (mesh.relayid) { nodeid = mesh.relayid; addr = node.host; } } // Setup device replay if needed
8017 - meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, ip: addr, tag: 'MCRouter', protocol: protocol, localport: localport }); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP, 6 = MCRDesktop, 7 = MCRFiles
8018 + if (node.mtype == 3) { if (mesh && mesh.relayid) { nodeid = mesh.relayid; addr = node.host; } } // Setup device replay if needed
8019 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, ip: addr, tag: 'MCRouter', protocol: protocol, localport: localport, name: mesh ? mesh.name : null }); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP, 6 = MCRDesktop, 7 = MCRFiles
8020 return false;
8021 }
8022
8023 function p10rfb(nodeid, port) {
8024 var node = getNodeFromId(nodeid), addr = null;
8025 + var mesh = meshes[node.meshid];
8026 if (port == null) { if (node.rfbport != null) { port = node.rfbport; } else { port = 5900; } }
8024 - if (node.mtype == 3) { var mesh = meshes[node.meshid]; if (mesh.relayid) { nodeid = mesh.relayid; addr = node.host; } } // Setup device replay if needed
8025 - meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tcpaddr: addr, tag: 'novnc' });
8027 + if (node.mtype == 3) { if (mesh && mesh.relayid) { nodeid = mesh.relayid; addr = node.host; } } // Setup device relay if needed
8028 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tcpaddr: addr, tag: 'novnc', name: mesh ? mesh.name : null });
8029 }
8030
8031 function p10mstsc(nodeid, port) {
8032 var node = getNodeFromId(nodeid);
8033 + var mesh = meshes[node.meshid];
8034 if (port == null) { if (node.rdpport != null) { port = node.rdpport; } else { port = 3389; } } // Adjust RDP port if needed
8031 - meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'mstsc' });
8035 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'mstsc', name: mesh ? mesh.name : null });
8036 }
8037
8038 function p10ssh(nodeid, port) {
8039 var node = getNodeFromId(nodeid);
8040 + var mesh = meshes[node.meshid];
8041 if (port == null) { if (node.sshport != null) { port = node.sshport; } else { port = 22; } }
8037 - meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'ssh' });
8042 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'ssh', name: mesh ? mesh.name : null });
8043 }
8044
8045 // Show current location